Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ハムスターの回し車の騒音問題に挑んだ話/hamster-LT
Search
kohei.okamoto
August 04, 2021
How-to & DIY
0
77
ハムスターの回し車の騒音問題に挑んだ話/hamster-LT
kohei.okamoto
August 04, 2021
Tweet
Share
More Decks by kohei.okamoto
See All by kohei.okamoto
四則演算を理解する/four-arithmetic-operations
koheiokamoto
0
290
空の色を計算してみた/calculate-sky-color
koheiokamoto
0
82
俺のオブジェクト指向/20200626LT
koheiokamoto
1
780
経験者がいない状態で、戦略的DDDを現場でやってみた話/ OOC2020
koheiokamoto
7
3.7k
Other Decks in How-to & DIY
See All in How-to & DIY
BlueTeamer勉強会 Security Onion編 激闘!Importノード
disconinja
1
220
人はなぜコミュニティとつながると幸せを感じるのか
448jp
3
260
AWSと学生支援 - Education-JAWS #0
awsjcpm
1
130
AWSコミュニティプログラムとJAWS-UGアップデート / JAWS-UG函館 勉強会 vol.14
awsjcpm
2
100
【加筆修正版】ハードワークを支えるフィジカルとメンタルを構築る#rubymusclemixin 活動 #きのこ2025 #きのこ2025_b
bash0c7
0
170
お家で育てる制御実験環境
zilmina
0
970
CH32Vシリーズを楽しもう(74thの場合) / enjoy ch32v series
74th
1
730
IoTカーテンオープナー
keicafeblack
0
360
Raspberry PiではじめるKiCad入門 / 20240226-rpi-jam
akkiesoft
1
4.2k
銀座線・半蔵門線から、ふりかえりカンファレンス2024現地会場への行き方
pokotyamu
0
280
PlatformIO IDE用M5Stack定型コード環境の紹介
3110
1
470
言語習得のベストプラクティス を考える
kanedaakihiro
0
130
Featured
See All Featured
How to Ace a Technical Interview
jacobian
276
23k
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
4 Signs Your Business is Dying
shpigford
183
22k
Optimizing for Happiness
mojombo
377
70k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
40
2k
Docker and Python
trallard
44
3.3k
Thoughts on Productivity
jonyablonski
69
4.5k
GraphQLの誤解/rethinking-graphql
sonatard
70
10k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
30
1.1k
GitHub's CSS Performance
jonrohan
1030
460k
Code Review Best Practice
trishagee
67
18k
Being A Developer After 40
akosma
90
590k
Transcript
ϋϜελʔͷճ͠ंͷ૽Ի ʹΜͩͳ͠ 2021/8/4 Ԭຊᕣฏ
ϋϜͪΌΜ • ϩϘϩϑεΩʔϋϜελʔ˂ • खʹ㕒ͷ͚ͬΔͱखΓͯ͘͠Δ ͕טΜͰ͘ΔͷͰΊͨ • ʹ΅͠ݏ͍ • ͻ·ΘΓͷछେ͖
γϦίϯεϓϨʔΛͯ͞͠ɾɾɾ ճ͠ं͕͏Δ͍͞ʂʂʂ
EventHandler
EventHandler
҉͘ͳͬͨΒϋϜͪΌΜ ΛরΒ͢Կ͔Λ࡞Γ͍ͨʂ
ϥζύΠͱ͔ͰղܾͰ͖ΔͷͰʁʁ (Πϝʔδ)
Arduino • ϚΠίϯϘʔυ (OSͱ͔ͳ͍) • ໊લͷ༝དྷߦ͖͚ͭͷόʔΒ͍͠ • ϥζύΠΑΓ͍҆ • Arduino༻ͷݴޠ/IDEΛͬͯ։ൃ͢Δ
CdSηϧ • ེԽΧυϛϜ • ޫ͕͋ͨΔͱɺޫిޮՌʹΑΓɺ ߅͕͘ͳΔ • II-VIͷΈ߹Θͤͷಋମ
None
Arduinoݴޠ const int LED = 9 ; int val =
0 ; void setup() { pinMode(LED,OUTPUT) ; } void loop() { val = analogRead(0) ; if (val > 500) { digitalWrite(LED, HIGH) ; } else { digitalWrite(LED, LOW) ; } delay(10) ; } • C++Έ͍ͨͳײ͡Ͱॻ͚ ΔΒ͍͠(C++Βͳ͍) • Arduino IDE͍ͩͿ͍· ͍ͪস
const int LED = 9 ; int val = 0
; void setup() { pinMode(LED,OUTPUT) ; } void loop() { val = analogRead(0) ; if (val > 500) { digitalWrite(LED, HIGH) ; } else { digitalWrite(LED, LOW) ; } delay(10) ; }
const int LED = 9 ; int val = 0
; void setup() { pinMode(LED,OUTPUT) ; } void loop() { val = analogRead(0) ; if (val > 500) { digitalWrite(LED, HIGH) ; } else { digitalWrite(LED, LOW) ; } delay(10) ; }
͜ΕͰɺ͋ͱճ࿏ΛΜͰ ࣮͢ΕOK!!!
ճ࿏͜Μͳײ͡
࣮͜Μͳײ ͡ const int LED = 9 ; const int
LIGHT_ON_BUFFER_TIME = 10 ; const int LIGHT_ON_MAX_TIME = 2000 ; boolean isLightOn = false ; boolean lightOnFlag = false ; int secondsDark = 0 ; int secondsLightOn = 0 ; void setup() { pinMode(LED,OUTPUT) ; } void loop() { delay(1000) ; int val = analogRead(0) ; if (val < 500) { roomDark() ; return ; } roomBright() ; } setup()Ͱ͏ϐϯΛએݴ͠ ͨޙʹɺ loop()͕ແݶʹ܁Γฦ͞Ε Δɻ
࣮͜Μͳײ ͡ void roomDark() { if (lightOnFlag) { // Ұ҉͍ؒʹ౮ࡁͳΒॲཧΛ͠ͳ͍
return ; } if (isLightOn) { if (secondsLightOn++ > LIGHT_ON_MAX_TIME) { lightOff() ; secondsLightOn = 0 ; lightOnFlag = true ; } } if (secondsDark++ > LIGHT_ON_BUFFER_TIME) { digitalWrite(LED, HIGH) ; isLightOn = true ; secondsDark = 0 ; } } void roomBright() { lightOff() ; isLightOn = false ; lightOnFlag = false ; secondsLightOn = 0 ; secondsDark = 0 ; } ͏গ͓͠͠ΌΕʹॻ͚Δ ؾ͢Δɾɾɾ
͜ΕͰArduinoଆʂ Ͱ͜Ε͚ͩͩͱύιίϯ͔Β֎͢ͱಈ͔ͳ͍ɾɾɾ
ACΞμϓλ͕ඞཁͳཧ༝ • ύιίϯ͔Βܨ͙ͱɺ5Vͷిѹ͕ڙڅ͞ΕΔɻ • ҰൠՈఉͷిѹ100V • ͳͷͰɺͦΕΛม͢ΔACΞμϓλ͔Βిݯڙڅ͢Δ͜ͱ͕ඞཁɻ
ArduinoਪACΞμϓλ • 9-12V • 250mAҎ্ • DC2.1 ϓϥά (֎ܘ:5.5Φɺܘ:2.1Φ) •
ηϯλʔϓϥε • ͋Μ·Γ͜͏͍͏෦ৄ͘͠ͳ͔ͬͨͷͰ͏͔ͬΓηϯλʔϚΠφ εͷACΞμϓλΛങͬͯ͠·ͬͨɾɾɾΈͳ͞Μ͝ҙΛɻɻ
None
ΊͪΌͬͨ
ײ • ؆୯ʂʂʂඵͰ࢝ΊΒΕΔʂ • ճ࿏ΛΉͱ͚ͩͪ͜ΐͬͱΉ͍ͣɻ • ߅͕͍͘Β͔ಡΉͷ׳Εͳ͍ɻ • ͜Μ͘Β͍؆୯ͳͷͳΒϥζύΠͱ͔͡Όͳ͍͍ͯ͘͢ͶɻͨͿΜ ֹ͘Β͍ɻ͏ͪΐ͍Ψνͳ͜ͱ͍ͨ͠ͳΒϥζύΠ͕͍͍ͷ͔ɻ
• ࠓޙന৭ͷLEDͳͲʹม͑ͯ࠶ઓ༧ఆ
͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ