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
65
ハムスターの回し車の騒音問題に挑んだ話/hamster-LT
kohei.okamoto
August 04, 2021
Tweet
Share
More Decks by kohei.okamoto
See All by kohei.okamoto
四則演算を理解する/four-arithmetic-operations
koheiokamoto
0
260
空の色を計算してみた/calculate-sky-color
koheiokamoto
0
67
俺のオブジェクト指向/20200626LT
koheiokamoto
1
730
経験者がいない状態で、戦略的DDDを現場でやってみた話/ OOC2020
koheiokamoto
7
3.6k
Other Decks in How-to & DIY
See All in How-to & DIY
GreenPAK 初心者向けハンズオン資料
aoisaya
2
170
DroidKaigi 2024 - 海外就職というキャリアの選択肢
iyotetsuya
1
510
コロナ後の世界メイカーフェア事情 高須正和@Nico-Tech Shenzhen #KMMF2024 #KariyaMMF2024
takasumasakazu
0
270
バタフライ効果/butterfly_effect
florets1
0
250
音に負けない!子どもが騒いでいる脇でも快適オンラインMTGの秘伝
kaitou
0
320
GPT-4oに遅刻理由を考えてもらうボタン #gpt_4o #iotlt #chatgpt
n0bisuke2
0
260
[너구리랑! 회고 밋업 2023] GTD & PARA -머릿속이 복잡하던 일상에 적용한 정리법 // 토르 님
develop_neoguri
1
340
中指立てたか判定IoT #iotlt #p5js
n0bisuke2
0
240
ちょっと待てぃ!!ボタンをキーボード化 #M5Stack #M5JPTour2023 #相席食堂
n0bisuke2
0
610
Why did my proposals get rejected?
okuramasafumi
1
470
IoTカーテンオープナー
keicafeblack
0
310
JAWS Days 2024 Keynote by Jeff Barr
awsjcpm
0
140
Featured
See All Featured
Fashionably flexible responsive web design (full day workshop)
malarkey
405
66k
Imperfection Machines: The Place of Print at Facebook
scottboms
266
13k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.5k
Fireside Chat
paigeccino
34
3.1k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
28
900
Making the Leap to Tech Lead
cromwellryan
133
9k
4 Signs Your Business is Dying
shpigford
181
21k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
The Cult of Friendly URLs
andyhume
78
6.1k
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ͳͲʹม͑ͯ࠶ઓ༧ఆ
͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ