Introduction: Make a Music Controlled Christmas Light With Arduino
Hi guys, Christmas is coming! Have you prepared your Christmas decorations for this year? If not, you better watch this. In this project I will show you how to decorate your Xmas Tree with music controlled LEDs.
Basically, the device I build in this project is programmed with Arduino, it can analyse the music rhythm in real-time, and use it as input, to control the color and flashing frequency of several strips of LEDs
It is really fun and can cheer up the atmosphere at once. You can check my video here.
When you finished this intructable, you can acquire the following knowledge:
- Be familiar with FHT library
- Master the Arduino programming
- The skills of dealing with music frequency spectrum
Step 1: What Do We Need to Build This
- 1x Seeeduino V4.2
- 1x Base Shield
- 4x Grove LED Strip
- 1x Music Player
- 1x Speaker
- 1x Chrismas Tree
Step 2: Wiring
I divided the musical notes I chose into 8 sections based on the octave, each section is in charge of one haft of a LED strip, as the picture shows below, there are 4 Led strips, so each Led strip is divided into two parts.
As we know, audio signals are AC(alternating currrent) signals, but the analog ports on Arduino analog port can only deal with DC(direct current) signals, so we need to design an input circuit, adding a bias voltage to the input Audio AC signal to make it work.
And here is the closeup of the universal board from above.
Step 3: Configure the ADC Sample Rate
The software work of this project is a bit more. Firstly we need to config the Arduino ADC sample rate to fast mode.
The Audio signal frequency is about 20KHz, but the default Arduino ADC sample rate is about 10K Hz, according to the Nyquist sampling theorem we know that the sample rate must be twice times greater than the signal frequency.
So we need to add the following code to our project.
<p>#if FASTADC<br> // set prescale to 16 sbi(ADCSRA,ADPS2) ; cbi(ADCSRA,ADPS1) ; cbi(ADCSRA,ADPS0) ; #endif</p>
The code below will config the ADC sample rate about 70K Hz and is fast enough for this project.
1. Download demo code at https://github.com/Lee-Kevin/ArduinoMusicFFT.
2. Click “Download zip” button on right side of webpage to download all codes.
3. Decompress the downloaded zip files to “C:\Users\Administrator\Documents\Arduino\” and remove “-master” in decompressed file name.
4. Launch Arduino IDE.
5. Click Sketch > Add file to add Music_FFT.ino file from “C:\Users\Administrator\Documents\Arduino\ArduinoMusicFFT\Music_FFT\”.
6. Click Tools -> Board and select “Arduino/Genuino Uno” and chose the right port, as shown in the picture below.
7. Press CTRL +U to upload codes to your board. Wait a while, there will be saying “Done uploading”.
8. Congratulations, you have already completed the software work.
Step 5: The Result
Place the LED strips on a Christmas tree.
Now you can plug a music player such as mobile phone to the device as well as a speaker, then play a strong sense of rhythm music and you’ll find the Led Strip will flash with the music.
Step 6: Make. Invent. Do.
This project is made as an Open Source Project. It's a starting point. Let your creativity go wild with the mechanical, electrical and software design. Make the demo your own. Decorate it. Improve the work. No matter what, write a recipe about it.
To share and progress together.
Participated in the
Arduino Contest 2016
Question 5 years ago on Step 4
Does this just turn on and off the lights or is there PWM happening as well?