Showing posts with label 未分類. Show all posts
Showing posts with label 未分類. Show all posts

Tuesday, April 17, 2018

IR Receive Arduino Code


  • Arduino GND --> Module pin -

  • Arduino +5V --> Module PLUS (middle pin)

  • Arduino Digital pin 11 --> Module S


 

[pastacode lang="c" manual="%23include%20%3CIRremote.h%3E%0A%0Aint%20RECV_PIN%20%3D%202%3B%20%2F%2F%20%E4%BD%BF%E7%94%A8%E6%95%B8%E4%BD%8D%E8%85%B3%E4%BD%8D2%E6%8E%A5%E6%94%B6%E7%B4%85%E5%A4%96%E7%B7%9A%E8%A8%8A%E8%99%9F%0AIRrecv%20irrecv(RECV_PIN)%3B%20%2F%2F%20%E5%88%9D%E5%A7%8B%E5%8C%96%E7%B4%85%E5%A4%96%E7%B7%9A%E8%A8%8A%E8%99%9F%E8%BC%B8%E5%85%A5%0Adecode_results%20results%3B%20%2F%2F%20%E5%84%B2%E5%AD%98%E8%A8%8A%E8%99%9F%E7%9A%84%E7%B5%90%E6%A7%8B%0A%0Avoid%20setup()%0A%7B%0A%20%20Serial.begin(115200)%3B%0A%20%20irrecv.blink13(true)%3B%20%2F%2F%20%E8%A8%AD%E7%82%BAtrue%E7%9A%84%E8%A9%B1%EF%BC%8C%E7%95%B6%E6%94%B6%E5%88%B0%E8%A8%8A%E8%99%9F%E6%99%82%EF%BC%8C%E8%85%B3%E4%BD%8D13%E7%9A%84LED%E4%BE%BF%E6%9C%83%E9%96%83%E7%88%8D%0A%20%20irrecv.enableIRIn()%3B%20%2F%2F%20%E5%95%9F%E5%8B%95%E6%8E%A5%E6%94%B6%0A%7D%0A%0Avoid%20loop()%20%7B%0A%20%20if%20(irrecv.decode(%26results))%20%7B%20%2F%2F%20%E6%8E%A5%E6%94%B6%E7%B4%85%E5%A4%96%E7%B7%9A%E8%A8%8A%E8%99%9F%E4%B8%A6%E8%A7%A3%E7%A2%BC%0A%20%20%20%20Serial.print(%22results%20value%20is%20%22)%3B%20%2F%2F%20%E8%BC%B8%E5%87%BA%E8%A7%A3%E7%A2%BC%E5%BE%8C%E7%9A%84%E8%B3%87%E6%96%99%0A%20%20%20%20Serial.print(results.value%2C%20HEX)%3B%0A%20%20%20%20Serial.print(%22%2C%20bits%20is%20%22)%3B%0A%20%20%20%20Serial.print(results.bits)%3B%0A%20%20%20%20Serial.print(%22%2C%20decode_type%20is%20%22)%3B%0A%20%20%20%20Serial.println(results.decode_type)%3B%0A%20%20%20%20irrecv.resume()%3B%20%2F%2F%20%E6%BA%96%E5%82%99%E6%8E%A5%E6%94%B6%E4%B8%8B%E4%B8%80%E5%80%8B%E8%A8%8A%E8%99%9F%0A%20%20%7D%0A%7D" message="" highlight="" provider="manual"/]

Monday, April 16, 2018

LCD I2C to Display A0 Voltage (0V - 5V)

[pastacode lang="c" manual="%23include%20%3CWire.h%3E%20%2F%2F%20Arduino%20IDE%20%E5%85%A7%E5%BB%BA%0A%2F%2F%20LCD%20I2C%20Library%EF%BC%8C%E5%BE%9E%E9%80%99%E8%A3%A1%E5%8F%AF%E4%BB%A5%E4%B8%8B%E8%BC%89%EF%BC%9A%0A%2F%2F%20bitbucket.org%2Ffmalpartida%2Fnew-liquidcrystal%2Fdownloads%0A%23include%20%3CLiquidCrystal_I2C.h%3E%0A%0A%2F%2F%20Set%20the%20pins%20on%20the%20I2C%20chip%20used%20for%20LCD%20connections%3A%0A%2F%2F%20addr%2C%20en%2Crw%2Crs%2Cd4%2Cd5%2Cd6%2Cd7%2Cbl%2Cblpol%0ALiquidCrystal_I2C%20lcd(0x27%2C%202%2C%201%2C%200%2C%204%2C%205%2C%206%2C%207%2C%203%2C%20POSITIVE)%3B%20%2F%2F%20%E8%A8%AD%E5%AE%9A%20LCD%20I2C%20%E4%BD%8D%E5%9D%80%0Afloat%20sensorValue0%20%3D%200.0%3B%0Afloat%20sensorValue1%20%3D%200.0%3B%0AString%20title%20%3D%20%22Output%20Voltage%22%3B%0A%0A%2F%2F%23define%20MIN_VALUE%200%3B%20%20%20%20%2F%2FINPUT%20RANGE%200-1023%0A%23define%20MAX_VALUE%201023.0%0A%0A%2F%2F%23define%20DISPLAY_MIN%200%3B%20%20%2F%2FDISPLAY%20RANGE%200V-5V%0A%23define%20DISPLAY_MAX%205.0%0A%0A%0A%0Avoid%20setup()%20%7B%0ASerial.begin(9600)%3B%20%2F%2F%20%E7%94%A8%E6%96%BC%E6%89%8B%E5%8B%95%E8%BC%B8%E5%85%A5%E6%96%87%E5%AD%97%0Alcd.begin(16%2C%202)%3B%20%2F%2F%20%E5%88%9D%E5%A7%8B%E5%8C%96%20LCD%EF%BC%8C%E4%B8%80%E8%A1%8C%2016%20%E7%9A%84%E5%AD%97%E5%85%83%EF%BC%8C%E5%85%B1%202%20%E8%A1%8C%EF%BC%8C%E9%A0%90%E8%A8%AD%E9%96%8B%E5%95%9F%E8%83%8C%E5%85%89%0A%0A%2F%2F%20%E9%96%83%E7%88%8D%E4%B8%80%E6%AC%A1%0Afor(int%20i%20%3D%200%3B%20i%20%3C%201%3B%20i%2B%2B)%20%7B%0Alcd.backlight()%3B%20%2F%2F%20%E9%96%8B%E5%95%9F%E8%83%8C%E5%85%89%0Adelay(250)%3B%0Alcd.noBacklight()%3B%20%2F%2F%20%E9%97%9C%E9%96%89%E8%83%8C%E5%85%89%0Adelay(250)%3B%0A%7D%0Alcd.backlight()%3B%0A%0A%2F%2F%20%E8%BC%B8%E5%87%BA%E5%88%9D%E5%A7%8B%E5%8C%96%E6%96%87%E5%AD%97%0Alcd.setCursor(0%2C%200)%3B%20%2F%2F%20%E8%A8%AD%E5%AE%9A%E6%B8%B8%E6%A8%99%E4%BD%8D%E7%BD%AE%E5%9C%A8%E7%AC%AC%E4%B8%80%E8%A1%8C%E8%A1%8C%E9%A6%96%0Alcd.print(%22HK%20STEM%20CLUB%22)%3B%0Alcd.setCursor(0%2C%201)%3B%20%2F%2F%20%E8%A8%AD%E5%AE%9A%E6%B8%B8%E6%A8%99%E4%BD%8D%E7%BD%AE%E5%9C%A8%E7%AC%AC%E4%BA%8C%E8%A1%8C%E8%A1%8C%E9%A6%96%0Alcd.print(%22hkstem.club%22)%3B%0Adelay(500)%3B%0A%0A%7D%0A%0Avoid%20loop()%20%7B%0A%20%20lcd.clear()%3B%0A%20%20int%20analog_value%20%3D%20analogRead(A0)%3B%0A%20%20sensorValue0%20%3D%20analog_value%20%2F%20MAX_VALUE%3B%20%2F%2F%20read%20the%20input%20on%20analog%20pin%200%3A%0A%20%20%0A%20%20%2F%2F%20print%20out%20the%20sensor%3A%0A%20%20lcd.setCursor(0%2C%200)%3B%0A%20%20lcd.print(sensorValue0%20*%20DISPLAY_MAX)%3B%0A%20%20Serial.println(analog_value%20%2F%201023.0)%3B%0A%0A%20%20lcd.setCursor(0%2C1)%3B%0A%20%20%2F%2Flcd.print(sensorValue1)%3B%0A%20%20lcd.print(title)%3B%0A%0A%20%20sensorValue1%20%3D%20sensorValue0%3B%0A%20%20%0A%20%20delay(300)%3B%20%20%20%20%20%20%20%20%2F%2F%20delay%20in%20between%20reads%20for%20stability%0A%0A%0A%7D" message="" highlight="" provider="manual"/]

I2C Scanner

[pastacode lang="c" manual="%2F%2F%20--------------------------------------%0A%2F%2F%20i2c_scanner%0A%2F%2F%0A%2F%2F%20Version%201%0A%2F%2F%20This%20program%20(or%20code%20that%20looks%20like%20it)%0A%2F%2F%20can%20be%20found%20in%20many%20places.%0A%2F%2F%20For%20example%20on%20the%20Arduino.cc%20forum.%0A%2F%2F%20The%20original%20author%20is%20not%20know.%0A%2F%2F%20Version%202%2C%20Juni%202012%2C%20Using%20Arduino%201.0.1%0A%2F%2F%20Adapted%20to%20be%20as%20simple%20as%20possible%20by%20Arduino.cc%20user%20Krodal%0A%2F%2F%20Version%203%2C%20Feb%2026%202013%0A%2F%2F%20V3%20by%20louarnold%0A%2F%2F%20Version%204%2C%20March%203%2C%202013%2C%20Using%20Arduino%201.0.3%0A%2F%2F%20by%20Arduino.cc%20user%20Krodal.%0A%2F%2F%20Changes%20by%20louarnold%20removed.%0A%2F%2F%20Scanning%20addresses%20changed%20from%200...127%20to%201...119%2C%0A%2F%2F%20according%20to%20the%20i2c%20scanner%20by%20Nick%20Gammon%0A%2F%2F%20http%3A%2F%2Fwww.gammon.com.au%2Fforum%2F%3Fid%3D10896%0A%2F%2F%20Version%205%2C%20March%2028%2C%202013%0A%2F%2F%20As%20version%204%2C%20but%20address%20scans%20now%20to%20127.%0A%2F%2F%20A%20sensor%20seems%20to%20use%20address%20120.%0A%2F%2F%20Version%206%2C%20November%2027%2C%202015.%0A%2F%2F%20Added%20waiting%20for%20the%20Leonardo%20serial%20communication.%0A%2F%2F%0A%2F%2F%0A%2F%2F%20This%20sketch%20tests%20the%20standard%207-bit%20addresses%0A%2F%2F%20Devices%20with%20higher%20bit%20address%20might%20not%20be%20seen%20properly.%0A%2F%2F%0A%0A%23include%20%3CWire.h%3E%0A%0Avoid%20setup()%0A%7B%0AWire.begin()%3B%0A%0ASerial.begin(9600)%3B%0Awhile%20(!Serial)%3B%20%2F%2F%20Leonardo%3A%20wait%20for%20serial%20monitor%0ASerial.println(%22%5CnI2C%20Scanner%22)%3B%0A%7D%0A%0Avoid%20loop()%0A%7B%0Abyte%20error%2C%20address%3B%0Aint%20nDevices%3B%0A%0ASerial.println(%22Scanning...%22)%3B%0A%0AnDevices%20%3D%200%3B%0Afor(address%20%3D%201%3B%20address%20%3C%20127%3B%20address%2B%2B%20)%0A%7B%0A%2F%2F%20The%20i2c_scanner%20uses%20the%20return%20value%20of%0A%2F%2F%20the%20Write.endTransmisstion%20to%20see%20if%0A%2F%2F%20a%20device%20did%20acknowledge%20to%20the%20address.%0AWire.beginTransmission(address)%3B%0Aerror%20%3D%20Wire.endTransmission()%3B%0A%0Aif%20(error%20%3D%3D%200)%0A%7B%0ASerial.print(%22I2C%20device%20found%20at%20address%200x%22)%3B%0Aif%20(address%3C16)%0ASerial.print(%220%22)%3B%0ASerial.print(address%2CHEX)%3B%0ASerial.println(%22%20!%22)%3B%0A%0AnDevices%2B%2B%3B%0A%7D%0Aelse%20if%20(error%3D%3D4)%0A%7B%0ASerial.print(%22Unknown%20error%20at%20address%200x%22)%3B%0Aif%20(address%3C16)%0ASerial.print(%220%22)%3B%0ASerial.println(address%2CHEX)%3B%0A%7D%0A%7D%0Aif%20(nDevices%20%3D%3D%200)%0ASerial.println(%22No%20I2C%20devices%20found%5Cn%22)%3B%0Aelse%0ASerial.println(%22done%5Cn%22)%3B%0A%0Adelay(5000)%3B%20%2F%2F%20wait%205%20seconds%20for%20next%20scan%0A%7D" message="" highlight="" provider="manual"/]

Monday, April 24, 2017

LazyTomato Lab 軟爛番茄工作室

一群熱 (ㄊㄧㄢ) 血 (ㄓㄣ) 的台灣工程師、設計師與跨領域創作者,
致力於開源社群 (Open Source) 與開放教育 (OER) 的耕耘。
我們是 LazyTomato Lab 軟爛番茄工作室!

免費又優質的好頻道,不追蹤嗎?ヽ(●´∀`●)ノ

✏ 官方網站:http://www.lazytomatolab.com/
✏ 頻道網址:https://www.youtube.com/c/LazyTomatoLab
✏ 範例程式:https://gist.github.com/lazytomatolab

 

【軟爛番茄小檔案】

栽種作物特色:
✏ 精簡扼要、清楚說明、循序漸進

目前栽種項目:
✏ Arduino 教學、自造者 (Maker) 運動

Arduino 教學系列:
✏ LazyTomato Lab 秉持開源與開放精神,將「看起來很難」、「自己摸索不容易」、「沒有資源或機會去聽課」等喪失踏 (誤) 入 Arduino 學習之路的困擾排除,打造一個利於自造者 (Maker) 「熱愛自主學習」的優良環境。課程中也設計了大量的專題練習,幫助各位好學的 Maker 好消化、好吸收!

 

【內容授權】

LazyTomato Lab 之內容以創用 CC 姓名標示-非商業性-相同方式分享 4.0 國際授權條款釋出。
更多資訊請造訪:http://creativecommons.org/licenses/by-nc-sa/4.0/

 

https://www.youtube.com/watch?v=B4T8hzO0IYc

 

https://www.youtube.com/watch?v=TJ8IqbyuTu4

 

https://www.youtube.com/watch?v=6oh5jG1e-gQ

 

https://www.youtube.com/watch?v=hY33--luLYs

 

https://www.youtube.com/watch?v=xIlhSKaM4yo

 

https://www.youtube.com/watch?v=b-Dnn5djs9o

 

https://www.youtube.com/watch?v=cWEJMusT-hI

 

https://www.youtube.com/watch?v=8lfrjiA4nAg

 

 

Monday, April 17, 2017

Arduino Video Tutotial

Video

http://list.youku.com/albumlist/show?id=5058091&ascending=1&page=1

http://hkcn.rs-online.com/web/generalDisplay.html?id=arduino

Monday, April 3, 2017

Arduino 101

https://www.arduino.cc/en/Main/Products

 

 

入門級





 

進階 (較快 / 處理複雜的指令)