Ultrasonic RGB Led

by Splat in Circuits > Arduino

244 Views, 0 Favorites, 0 Comments

Ultrasonic RGB Led

DSCF3023.JPG
DSCF3018.JPG
DSCF3022.JPG
DSCF3020.JPG
DSCF3021.JPG

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

DSCF3028.JPG
DSCF3035.JPG
DSCF3040.JPG
DSCF3029.JPG
DSCF3032.JPG
DSCF3030.JPG
DSCF3048.JPG
  • RGB led 1x
  • 220 ohm resistors 3x
  • HC-SR04 ultrasonic sensor 1x
  • Arduino Uno R3 1x
  • Breadboard 1x
  • Jumper wires 8x
  • Battery pack 1x

DSCF3033.JPG
DSCF3034.JPG
DSCF3031.JPG
DSCF3036.JPG
DSCF3037.JPG
DSCF3038.JPG
DSCF3039.JPG

Attach the RGB led as shown. make sure that the red green and blue pins are positive.

DSCF3024.JPG
DSCF3041.JPG
DSCF3042.JPG
DSCF3043.JPG
DSCF3044.JPG
DSCF3045.JPG
DSCF3046.JPG
DSCF3047.JPG

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

DSCF3058.JPG
DSCF3054.JPG
DSCF3055.JPG
DSCF3056.JPG
DSCF3057.JPG

After you upload the code it should work. If you have any questions, leave them in the comments.