Ultrasonic RGB Led
This is my first Arduino project that I have posted. It uses an ultrasonic sensor to determine how far your hand is from the sensor. If it is 10cm or less,the RGB led turns red. If it is 15cm or less,the RGB led turns green. if it is 20cm or less the RGB led is blue. Finally if it is greater than 20 the RGB led turns off. I couldn't find out how to make other colors,but if you know of a way please leave a link to the code in the comments.
Supplies
- RGB led 1x
- 220 ohm resistors 3x
- HC-SR04 ultrasonic sensor 1x
- Arduino Uno R3 1x
- Breadboard 1x
- Jumper wires 8x
- Battery pack 1x
Attach the RGB led as shown. make sure that the red green and blue pins are positive.
Attach the ultrasonic sensor a shown. Ground goes to ground, Vcc goes to 5v, echo goes to pin 4, and trigger goes to pin 5.
The Code
After you upload the code it should work. If you have any questions, leave them in the comments.