HC-SR04 與 NewPing Library的結合
若您覺得文章寫得不錯,請點選文章上的廣告,來支持小編,謝謝。 最近在臉書上看到一篇文章:「 原來超音波只要用echo腳位就好 」。原作是在Microbit上使用,筆者就開始想在Arduino上試試看,底下為筆者搭配 Arduino New Ping 的成功做法。 硬體材料: Arduino UNO R3 板子 x 1 杜邦線母對母 x 7 330歐姆電阻 x 1 Arduino Sensor Shield x 1 HC-SR04 x 1 SSD1306 I2C 0.96 吋 OLED 顯示模組 x 1 麵包版 x 1 硬體電路: 接線方式: 將HC-SR04 接在麵包版上,使用330歐姆的電阻將HC-SR04的 Echo 與 Trig 給接在一起。 HC-SR04 的 Echo 接到 Arduino Sensor Shield Pin 12 OLED 的 SCL 接到 Arduino Sensor Shield SCL OLED 的 SDA 接到 Arduino Sensor Shield SDA 安裝 Arduino New Ping 與 OLED的程式庫: https://bitbucket.org/teckel12/arduino-new-ping/wiki/Home https://github.com/adafruit/Adafruit_SSD1306 https://github.com/adafruit/Adafruit-GFX-Library Arduino IDE 程式碼: 示範影片: