Introduction: Ping Sensor Controlled RGB LEDS
As part of my project this semester I needed to be able to control some RGB LEDs using a ping sensor. For my project I wanted my LEDs to fade through colors but when someone got too close to the project I wanted the LEDs to turn red and stay red as long as the person or object was too close.
For this project you are going to need:
Once you get the project working and you decide to make it permeant you will need:
Soldering Iron, Solder, Wire, a prototyping board, and a case to put the project in. I made my case using wood and acrylic.
Step 1: Testing Your Parts
Before we begin we need to test all of parts to make sure that they each work.
To test and use the ping sensor you need to download and install the NewPing Library which can be found here
Then you need to connect the sensor to the arduino board. The ground goes to ground, echo to pin 11, trigger to pin 12, and the last pin goes to the 5volt pin.
Next go to the NewPing folder and open the test code in the folder called NewPingExample. Check the code then upload it to the arduino. After that Open the serial monitor and move your had around in front of the sensor. If you see it giving you a bunch of numbers then it is working.
Next we need to check the RGB LEDs. In order to do that I suggest you follow THIS tutorial first and then come back here.
Step 2: Putting It All Together
Now it is time to put it all together.
Connect the Ping Sensor and the RGB LEDs to the arduino at the same time in the same places as mentioned above. Then put the code below on the arduino. It should all work. I am still working some kinks out of the code so right now the Ping Sensor will only send out a ping once the color fade has stopped. Once I get it working better I will update the codes here.