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
68
ハムスターの回し車の騒音問題に挑んだ話/hamster-LT
kohei.okamoto
August 04, 2021
Tweet
Share
More Decks by kohei.okamoto
See All by kohei.okamoto
四則演算を理解する/four-arithmetic-operations
koheiokamoto
0
270
空の色を計算してみた/calculate-sky-color
koheiokamoto
0
71
俺のオブジェクト指向/20200626LT
koheiokamoto
1
740
経験者がいない状態で、戦略的DDDを現場でやってみた話/ OOC2020
koheiokamoto
7
3.6k
Other Decks in How-to & DIY
See All in How-to & DIY
Snowflake WEST ユーザー会第2回「ハンズオンセッション」
mabokaneko0802
0
230
JAWS-UG山梨第0回 AWSのユーザーコミュニティ支援
awsjcpm
0
130
Earthquake and Kominka
ramtop
0
150
CH32Vシリーズを楽しもう(74thの場合) / enjoy ch32v series
74th
1
450
BVEと連動する誤自宅運転台のススメ!
usashirou
0
690
さらなるアウトプットに、Let's ライトニングトーク! ― LTのやり方
ma2shita
2
740
球体型ロボットと複合現実を活用したマルチエージェントシステム - M5stack Japan Tour 2024 Spring Osaka
tichise
0
210
静岡県のお相撲さん20240509/sumo_wrestler_from_shizuoka_prefecture_20240509
nicepapa_hirano
0
130
スカウト返信率を倍にするためにやったこと / 2024-01-29
tamago3keran
2
980
「おうちクラウド」が今も熱い!
hirosat
2
1k
【バスケ】ボックススコアを用いたオールインワンメトリクス作成手続き
rnsr0371
0
460
「AITRIOS」でトカゲの活動量を可視化
hoshinoresearch
0
320
Featured
See All Featured
Side Projects
sachag
452
42k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
365
25k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
192
16k
Done Done
chrislema
182
16k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
29
960
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
7
570
Product Roadmaps are Hard
iamctodd
PRO
50
11k
Navigating Team Friction
lara
183
15k
Music & Morning Musume
bryan
46
6.3k
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ͳͲʹม͑ͯ࠶ઓ༧ఆ
͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ