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
Snowflake WEST ユーザー会第2回「ハンズオンセッション」
mabokaneko0802
0
200
ファシリテーターの美意識_株式会社コミュカル Mitz
comucal
PRO
0
250
ServiceNow Knowledgeの歩き方
manarobot
0
300
[너구리랑! 회고 밋업 2023] 비전공자 PM의 우당탕탕 2023년 // 의현 님
develop_neoguri
0
100
GreenPAK 初心者向けハンズオン資料
aoisaya
2
110
コロナ後の世界メイカーフェア事情 高須正和@Nico-Tech Shenzhen #KMMF2024 #KariyaMMF2024
takasumasakazu
0
250
ついにiPaaSでobnizが動くかも?! #iotlt #pipedream #obniz
n0bisuke2
0
320
一番やさしいDJ入門 2024
stefafafan
6
1.8k
「RubyでLチカ」に挑戦してみた
isaka1022
0
120
Earthquake and Kominka
ramtop
0
140
本気でコミュニティを成功させたいなら_株式会社コミュカル Mitz
comucal
PRO
0
810
PlatformIO IDE用M5Stack定型コード環境の紹介
3110
1
330
Featured
See All Featured
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
Designing Experiences People Love
moore
138
23k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
47
2.1k
Making the Leap to Tech Lead
cromwellryan
133
8.9k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
329
21k
YesSQL, Process and Tooling at Scale
rocio
169
14k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
16k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.3k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
840
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ͳͲʹม͑ͯ࠶ઓ༧ఆ
͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ