Introduction: Ultrasonic Party Starter
Have you ever wanted the party to start as soon as you enter the room? Now it can every time with the Ultrasonic Party Starter!
This project uses an Arduino and an HC-SR04 sensor to kickoff the party. If you are unfamiliar with the HC-SR04, it is an ultrasonic ranging module. They can be found for very cheap (I got mine on amazon for $3.77 -
It acts much like sonar - creating a pulse of sound or "ping," then measuring the time it takes for the echo to return. We will use it to detect when an object is within a certain range of the device and trigger an RGB LED to flash to the beat of Daft Punk's Aerodynamic.
If you are new to using the Arduino to play sounds, I suggest you start out with the tone tutorial found at the arduino website - http://www.arduino.cc/en/Tutorial/Tone.
If you have never used an ultrasonic ranging module try out http://www.arduino.cc/en/Tutorial/Ping.
The code I wrote for this device was inspired by both of these projects.
Now let's get this party started!
Step 1: Party Parts
The parts you will need:
0.5W speaker (8 ohm)
Potentiometer (for volume control)
RGB LED x 1
100 ohm resistor (brown black brown) x 1
330 ohm resistor (orange orange brown) x 3
Jumper wires x 17
Step 2: The Circuit
Use this diagram to guide you through each step.
Note: The wire colors in the diagram may not match the wire colors I used in the photographs.
Step 3: Connecting the Speaker
I used gator clips to connect the speaker to the leads. If you have a soldering iron, soldering the leads would be ideal. Run the circuit from pin 8 on the Arduino through the potentiometer, through the 100 ohm resistor, through the speaker, and back to the Aruino GND pin.
Step 4: Add the LED
The RGB LED has 4 cathodes. In my diagram, the cathodes from top to bottom are red, commond ground, green and blue. The flat side of the LED is facing the top of my diagram. Note that the longest cathode is the common ground. This should be connected to a ground pin on the Arduino.
Each cathode should be connected to the Arduino, separated by a 330 ohm resistor:
Red to pin 9
Green to pin 10
Blue to pin 11
Step 5: Connecting the HC-SR04
Now to connect our ultrasonic sensor. The sensor can be placed directly into the breadboard. Try not to let the wires in my diagram confuse you. I only used them to indicate where each pin should be placed within the circuit. The Fritzing software I used to create the diagram shows the sensor facing left but in reality we want it facing the right.
Gnd to ground
Echo to pin 13
Trig to pin 7
Vcc to 5v
Step 6: The Code
The code for this project includes the header file "pitches.h" borrowed from the toneMelody sketch in the tone tutorial I mentioned earlier. This file defines a frequency for every note. The pitches.h file must be in the same folder for the code to compile.