Arduino and HC-SR04

by sophia_yang in Circuits > Arduino

503 Views, 0 Favorites, 0 Comments

Arduino and HC-SR04

Arduino and HC-SR04
截圖 2020-04-12 下午2.45.23.png
截圖 2020-04-12 下午2.45.31.png

When you feel boring, you can try to make HC-SR04 with Arduino, it's very interesting!

(My ideas adapted from https://www.instructables.com/id/INTERFACING-HC-SR...)

This is an ultrasonic sensor project. When an object is close to it, the red LED will blink, when no object is close to it, the green LED will blink.

I add two LEDs and decorate my project.

(我製作方式來自於 https://www.instructables.com/id/INTERFACING-HC-SR...)

這是一個超音波感測器的主題。當物體接近它時,紅色的 LED 會閃爍,當沒有物體接近它時。綠色的 LED 會閃爍。

我加了兩個 LED 燈還有裝飾它。

Supplies

  • 1 Laptop
  • 1 Arduino
  • 1 HC-SR04
  • 2 LED (Red and Green)
  • 1 Electronics Breadboard
  • 1 USB Cable
  • 2 Resistors
  • Solid-core hookup wires

Prepare the Materials You Need!

下載.jpeg
unnamed.png
Arduino_Uno_-_R3.jpg
hook-up-wires-500x500.jpg

Please reference the "Supply" section above.

請參考上方"Supply"裡寫的材料準備。

Setting Up LED

aurduino_blink_a_led_vWO8I2YI9v.jpeg

Use a long hookup wire to connect the 5V signal on the Arduino to the left of the red row on the breadboard.

Use a long hookup wire to connect the GND signal on the Arduino to the left of the black row on the breadboard.

Place red LED to the left of the breadboard, and green LED to the right of the breadboard.

Take resistors and solid-core hookup wire and connect LEDs to the breadboard.

Connect the red LED to pin 11 and the green LED to pin 12.

拿一條線,並連接 Arduino 上的 5V 到麵包板上紅色那一條線的最左側。

再拿一條線,連接 Arduino 上的 GND 到麵包板上藍色那一條線的最左側。

把紅色的 LED 放到麵包版的左側,綠色的 LED 放到麵包版的右側。

拿電組和線連接 LED 燈到麵包版上。

將紅色的 LED 燈連接到 pin 11,綠色的 LED 燈連接到 pin 12。

Setting Up the HC-SR04

HCSR04.jpg
  • Connect Vcc to Arduino 5V
  • Connect Trig to Arduino pin 9
  • Connect Echo to Arduino pin 10
  • Connect Gnd to Arduino GND
  • 連接 Vcc 到 5V
  • 連接 Trig 到 pin 9
  • 連接 Echo 到 pin 10
  • 連接 Gnd 到 GND

Upload the Code

https://create.arduino.cc/editor/sophiay0622/629b7...

Download this code and upload to your board.

下載這個 code 並上傳到你的板子上。

Decorate Your Project !

IMG_4344.jpg
IMG_4345.jpg
IMG_4346.jpg
截圖 2020-04-12 下午2.44.23.png

Make sure if the code can upload to your board. Later, you can try to decorate your project.

確保 code 可以上傳到你的板子。之後,你可以試著裝飾你的板子。