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
63
ハムスターの回し車の騒音問題に挑んだ話/hamster-LT
kohei.okamoto
August 04, 2021
Tweet
Share
More Decks by kohei.okamoto
See All by kohei.okamoto
四則演算を理解する/four-arithmetic-operations
koheiokamoto
0
250
空の色を計算してみた/calculate-sky-color
koheiokamoto
0
61
俺のオブジェクト指向/20200626LT
koheiokamoto
1
710
経験者がいない状態で、戦略的DDDを現場でやってみた話/ OOC2020
koheiokamoto
7
3.6k
Other Decks in How-to & DIY
See All in How-to & DIY
データエンジニアのためのテクニカルサポートとLLM
yutomatsunoo
0
990
【1周年】Blueskyちゃん総集編を通じて青空を遊びつくそう
kawaiirailroads
0
260
IoTカーテンオープナー
keicafeblack
0
280
ServiceNow Knowledgeの歩き方
manarobot
0
290
【技術カンファレンス運営の裏側】Iwaken Lab 技術好き学生の近況報告 & ことみんさんに技術カンファレンス運営の裏側を聞いちゃう会
kotomin_m
4
210
LEGOでRecord Playerを作った話 #LEGOrdPlayer
keicafeblack
0
110
240420MapillaryMeetup2024Tokyo
tosseto
0
160
カフェでノートPCが盗難されたかどうかを検知するIoT #linedc #iotlt #obniz #protoout
n0bisuke2
1
270
わたしと技術コミュニティとキャリア
kotomin_m
2
170
Raspberry PiではじめるKiCad入門 / 20240226-rpi-jam
akkiesoft
1
3.3k
How to get hundreds of organic backlinks through statistics link building
ronishehu
0
130
Learning from Firefighters
ksatirli
PRO
0
130
Featured
See All Featured
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
790
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
3
370
Fontdeck: Realign not Redesign
paulrobertlloyd
81
5.2k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Building Better People: How to give real-time feedback that sticks.
wjessup
363
19k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
How GitHub (no longer) Works
holman
311
140k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
14
1.9k
Being A Developer After 40
akosma
86
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ͳͲʹม͑ͯ࠶ઓ༧ఆ
͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ