Introduction: Automated Christmas Lights
In this Instructable, I show you how to build Automatically Blinking Christmas Lights when music is played! The project has 2 parts: the Electrical Circuitry, and the Arduino Code/Algorithm. The circuit works by using an 8 channel relay to close the circuit in each of the 8 individual Christmas light strands. An electret microphone captures the sound waves playing on a set of speakers and sends it into an Arduino using an analog input.
From here there are 2 options for usable programs. You can use the manual code template to manually blink certain strands of lights for specific music tracks, or you can use the automatic code which activates different strands of wire based on the frequency played.
Step 1: Obtain Materials
The materials list for this project is very mild making it a very affordable project. The list of materials and where I purchased everything (amazon affiliate links) include:
1x Arduino Uno http://amzn.to/2DcHQYg
1x Breadboard https://www.digikey.com/product-detail/en/bud-ind...
1x Electret Microphone Amplifier https://www.adafruit.com/product/1713
1x Jumper Wire Bundle 65 PCS https://www.digikey.com/product-detail/en/bud-industries/BC32625/377-2093-ND/4156446
1x Premium Female/Male Jumper Wires - 20 x 12" https://www.adafruit.com/product/1713
1x SunFounder 8 Channel Relay http://amzn.to/2FAwJWH
8x Vickerman Mini Christmas Lights (can also purchase less strands) http://amzn.to/2FEAoD1
It is also worth noting rubber gloves and a fire extinguisher are highly recommended if you are new to these types of projects. There is also a PDF downloadable version of the materials list below.
Attachments
Step 2: Electrical - Connecting the Relay and Christmas Lights
The heart of the electrical circuitry is the relay. A relay is a mechanical switch which closes when a much smaller voltage is applied to the relay. This works because the smaller voltage runs through a coil of wire, which creates an electromagnet to close the mechanical switch. The switch is connected to the same cut end of each Christmas Light strand. When the switch closes, voltage of the wall outlet is able to run through the strand, creating light!
Note: DO NOT work on the Christmas light strands while the lights are plugged in!
To connect the lights to the relay, make a single cut into the light strand and strip the wire slightly to reveal a small amount of copper on each side of the cut. Once that is done, connect each copper tip to the normally open leads of 1 relay. Do this for 8 light strands.
More on how to connect the relay can be found here: https://www.sunfounder.com/learn/From-Knowing-To-...
Step 3: Electrical - Microphone and Arduino
Next, we need to connect the electret microphone to Arduino so we can start receiving sound waves as analog input. The connections are fairly simple with the microphone VCC and ground connecting to the Arduino 5V and ground respectively, the microphone output connects directly to the Arduino analog 0 pin. The images above and visual Fritzing circuit below detail how the microphone and relay board connect to Arduino.
Attachments
Step 4: Arduino Code - Automatic Blinking Lights
After connecting all of the electronics, it's time to upload Arduino code! The automatic blinking lights code will cause the Christmas lights to automatically blink based on the frequency of the sound the microphone hears. The code works by using an algorithm called FHT (Fast Hartley Transform) similar to FFT (Fast Fourier Transform) to convert the sound wave from the time domain to the frequency domain.
I don't usually like to use specialized libraries when I write code, but the library over at open music labs was extremely easy to work with and made this project a lot quicker! The code will be available on my GitHub repository: https://github.com/RoboAvatar65/LightControl
Step 5: Arduino Code - Manual Blinking Lights
My GitHub repository also contains code for manually blinking lights. The manual code in this repository is currently calibrated for Carol of Bells but you can change the code to blink to any song by following the same pattern I use in this code! The code will also be available on GitHub: https://github.com/RoboAvatar65/LightControl
Step 6: Setup the Lights and Run the Code!
Places your lights where you want them, upload your code to the Arduino board and watch your light show! Once you're done and it works, you can power your Arduino with a 9V battery so you don't need to keep your laptop nearby. Enjoy the show!
7 Comments
Question 3 years ago
What is the bias integer for?
Question 4 years ago on Step 6
so after I uploaded the code, the program doesn't work as expected. how do i fix it, it seems that is not registering any frequency. how do i see the frequencies that it is registering?
Question 4 years ago
Some help me out that how to combine this the serial pin is same bat void setup and void loop is which run in arduino uno 8 relay
Part 1
int tree1 = 2;
int tree2 = 3;
int tree3 = 4;
int tree4 = 5;
int tree5 = 6;
int tree6 = 7;
int tree7 = 8;
int tree8 = 9;
int s = 150;
int ds = 225;
int e = 300;
int de = 450;
int q = 600;
int dq = 900;
int h = 1200;
int dh = 1800;
int pPin = 10;
void setup()
{
pinMode(tree1, OUTPUT);
pinMode(tree2, OUTPUT);
pinMode(tree3, OUTPUT);
pinMode(tree4, OUTPUT);
pinMode(tree5, OUTPUT);
pinMode(tree6, OUTPUT);
pinMode(tree7, OUTPUT);
pinMode(tree8, OUTPUT);
digitalWrite(tree1,LOW);
delay(1000);
digitalWrite(tree2,LOW);
delay(1000);
digitalWrite(tree3,LOW);
delay(1000);
digitalWrite(tree4,LOW);
delay(1000);
digitalWrite(tree5,LOW);
delay(1000);
digitalWrite(tree6,LOW);
delay(1000);
digitalWrite(tree7,LOW);
delay(1000);
digitalWrite(tree8,LOW);
delay(1000);
digitalWrite(tree1,HIGH);
digitalWrite(tree2,HIGH);
digitalWrite(tree3,HIGH);
digitalWrite(tree4,HIGH);
digitalWrite(tree5,HIGH);
digitalWrite(tree6,HIGH);
digitalWrite(tree7,HIGH);
digitalWrite(tree8,HIGH);
}
void loop()
{
// event 1
noTone(pPin);
digitalWrite(tree1, LOW);
digitalWrite(tree8, LOW);
tone(pPin, 261.63); // c4
delay(q);
noTone(pPin);
digitalWrite(tree1, HIGH);
digitalWrite(tree8, HIGH);
// event 2
digitalWrite(tree2, LOW);
digitalWrite(tree7, LOW);
tone(pPin, 246.94); // b3
delay(de);
noTone(pPin);
digitalWrite(tree2, HIGH);
digitalWrite(tree7, HIGH);
// event 3
digitalWrite(tree3, LOW);
digitalWrite(tree6, LOW);
tone(pPin, 220); // a3
delay(s);
noTone(pPin);
digitalWrite(tree3, HIGH);
digitalWrite(tree6, HIGH);
// event 4
digitalWrite(tree4, LOW);
digitalWrite(tree5, LOW);
tone(pPin, 196); // g3
delay(1050);
noTone(pPin);
digitalWrite(tree4, HIGH);
digitalWrite(tree5, HIGH);
// event 5
digitalWrite(tree1, LOW);
digitalWrite(tree8, LOW);
tone(pPin, 174.61); //f3
delay(s);
noTone(pPin);
digitalWrite(tree1, HIGH);
digitalWrite(tree8, HIGH);
// event 6
digitalWrite(tree2, LOW);
digitalWrite(tree7, LOW);
tone(pPin, 164.81); //e3
delay(q);
noTone(pPin);
digitalWrite(tree2, HIGH);
digitalWrite(tree7, HIGH);
// event 7
digitalWrite(tree3, LOW);
digitalWrite(tree6, LOW);
tone(pPin, 146.83); // d3
delay(q);
noTone(pPin);
digitalWrite(tree3, HIGH);
digitalWrite(tree6, HIGH);
// event 8
digitalWrite(tree4, LOW);
digitalWrite(tree5, LOW);
tone(pPin, 130.81); //c3
delay(dq);
noTone(pPin);
digitalWrite(tree4, HIGH);
digitalWrite(tree5, HIGH);
// event 9
digitalWrite(tree1, LOW);
digitalWrite(tree2, LOW);
digitalWrite(tree7, LOW);
digitalWrite(tree8, LOW);
tone(pPin, 196); // g3
delay(e);
noTone(pPin);
digitalWrite(tree1, HIGH);
digitalWrite(tree2, HIGH);
digitalWrite(tree7, HIGH);
digitalWrite(tree8, HIGH);
// event 10
digitalWrite(tree2, LOW);
digitalWrite(tree3, LOW);
digitalWrite(tree6, LOW);
digitalWrite(tree7, LOW);
tone(pPin, 220); // a3
delay(dq);
noTone(pPin);
digitalWrite(tree2, HIGH);
digitalWrite(tree3, HIGH);
digitalWrite(tree6, HIGH);
digitalWrite(tree7, HIGH);
// event 11
digitalWrite(tree1, LOW);
digitalWrite(tree2, LOW);
digitalWrite(tree7, LOW);
digitalWrite(tree8, LOW);
tone(pPin, 220); // a3
delay(e);
noTone(pPin);
digitalWrite(tree1, HIGH);
digitalWrite(tree2, HIGH);
digitalWrite(tree7, HIGH);
digitalWrite(tree8, HIGH);
// event 12
digitalWrite(tree3, LOW);
digitalWrite(tree4, LOW);
digitalWrite(tree5, LOW);
digitalWrite(tree6, LOW);
tone(pPin, 246.94); //b3
delay(dq);
noTone(pPin);
digitalWrite(tree3, HIGH);
digitalWrite(tree4, HIGH);
digitalWrite(tree5, HIGH);
digitalWrite(tree6, HIGH);
// event 13
digitalWrite(tree1, LOW);
digitalWrite(tree2, LOW);
digitalWrite(tree7, LOW);
digitalWrite(tree8, LOW);
tone(pPin, 246.94); //b3
delay(e);
noTone(pPin);
digitalWrite(tree1, HIGH);
digitalWrite(tree2, HIGH);
digitalWrite(tree7, HIGH);
digitalWrite(tree8, HIGH);
// event 14
digitalWrite(tree1, LOW);
digitalWrite(tree2, LOW);
digitalWrite(tree3, LOW);
digitalWrite(tree4, LOW);
digitalWrite(tree5, LOW);
digitalWrite(tree6, LOW);
digitalWrite(tree7, LOW);
digitalWrite(tree8, LOW);
tone(pPin, 261.63); //c4
delay(dq);
noTone(pPin);
digitalWrite(tree1, HIGH);
digitalWrite(tree2, HIGH);
digitalWrite(tree3, HIGH);
digitalWrite(tree4, HIGH);
digitalWrite(tree5, HIGH);
digitalWrite(tree6, HIGH);
digitalWrite(tree7, HIGH);
digitalWrite(tree8, HIGH);
// event 15
digitalWrite(tree8, LOW);
tone(pPin, 261.63); //c4
delay(e);
noTone(pPin);
digitalWrite(tree8, HIGH);
// event 16
digitalWrite(tree1, LOW);
tone(pPin, 261.63); //c4
delay(e);
noTone(pPin);
digitalWrite(tree1, HIGH);
// event 17
digitalWrite(tree7, LOW);
tone(pPin, 246.94); //b3
delay(e);
noTone(pPin);
digitalWrite(tree7, HIGH);
// event 18
digitalWrite(tree2, LOW);
tone(pPin, 220); //a3
delay(e);
noTone(pPin);
digitalWrite(tree2, HIGH);
// event 19
digitalWrite(tree6, LOW);
tone(pPin, 196); //g3
delay(e);
noTone(pPin);
digitalWrite(tree6, HIGH);
// event 20
digitalWrite(tree3, LOW);
tone(pPin, 196); //g3
delay(de);
noTone(pPin);
digitalWrite(tree3, HIGH);
// event 21
digitalWrite(tree5, LOW);
tone(pPin, 174.61); //f3
delay(s);
noTone(pPin);
digitalWrite(tree5, HIGH);
// event 22
digitalWrite(tree4, LOW);
tone(pPin, 164.81); //e3
delay(e);
noTone(pPin);
digitalWrite(tree4, HIGH);
// event 23
digitalWrite(tree8, LOW);
tone(pPin, 261.63); //c4
delay(e);
noTone(pPin);
digitalWrite(tree8, HIGH);
// event 24
digitalWrite(tree1, LOW);
tone(pPin, 261.63); //c4
delay(e);
noTone(pPin);
digitalWrite(tree1, HIGH);
// event 25
digitalWrite(tree7, LOW);
tone(pPin, 246.94); //b3
delay(e);
noTone(pPin);
digitalWrite(tree7, HIGH);
// event 26
digitalWrite(tree2, LOW);
tone(pPin, 220); //a3
delay(e);
noTone(pPin);
digitalWrite(tree2, HIGH);
// event 27
digitalWrite(tree6, LOW);
tone(pPin, 196); //g3
delay(e);
noTone(pPin);
digitalWrite(tree6, HIGH);
// event 27
digitalWrite(tree3, LOW);
tone(pPin, 196); //g3
delay(de);
noTone(pPin);
digitalWrite(tree3, HIGH);
// event 29
digitalWrite(tree5, LOW);
tone(pPin, 174.61); //f3
delay(s);
noTone(pPin);
digitalWrite(tree5, HIGH);
// event 30
digitalWrite(tree4, LOW);
tone(pPin, 164.81); //e3
delay(e);
noTone(pPin);
digitalWrite(tree4, HIGH);
// event 31
digitalWrite(tree2, LOW);
digitalWrite(tree7, LOW);
tone(pPin, 164.81); //e3
delay(e);
noTone(pPin);
digitalWrite(tree2, HIGH);
digitalWrite(tree7, HIGH);
// event 32
digitalWrite(tree1, LOW);
digitalWrite(tree8, LOW);
tone(pPin, 164.81); //e3
delay(e);
noTone(pPin);
digitalWrite(tree1, HIGH);
digitalWrite(tree8, HIGH);
// event 33
digitalWrite(tree2, LOW);
digitalWrite(tree7, LOW);
tone(pPin, 164.81); //e3
delay(e);
noTone(pPin);
digitalWrite(tree2, HIGH);
digitalWrite(tree7, HIGH);
// event 34
digitalWrite(tree1, LOW);
digitalWrite(tree8, LOW);
tone(pPin, 164.81); //e3
delay(e);
noTone(pPin);
digitalWrite(tree1, HIGH);
digitalWrite(tree8, HIGH);
// event 35
digitalWrite(tree2, LOW);
digitalWrite(tree7, LOW);
tone(pPin, 164.81); //e3
delay(75);
noTone(pPin);
digitalWrite(tree2, HIGH);
digitalWrite(tree7, HIGH);
// event 36
digitalWrite(tree3, LOW);
digitalWrite(tree6, LOW);
tone(pPin, 174.61); //f3
delay(75);
noTone(pPin);
digitalWrite(tree3, HIGH);
digitalWrite(tree6, HIGH);
// event 37
digitalWrite(tree4, LOW);
digitalWrite(tree5, LOW);
tone(pPin, 196); //g3
delay(dq);
noTone(pPin);
digitalWrite(tree4, HIGH);
digitalWrite(tree5, HIGH);
// event 38
digitalWrite(tree4, LOW);
digitalWrite(tree5, LOW);
tone(pPin, 174.61); //f3
delay(75);
noTone(pPin);
digitalWrite(tree4, HIGH);
digitalWrite(tree5, HIGH);
// event 39
digitalWrite(tree3, LOW);
digitalWrite(tree6, LOW);
tone(pPin, 164.81); //e3
delay(75);
noTone(pPin);
digitalWrite(tree3, HIGH);
digitalWrite(tree6, HIGH);
// event 40
digitalWrite(tree4, LOW);
digitalWrite(tree5, LOW);
tone(pPin, 146.83); //d3
delay(e);
noTone(pPin);
digitalWrite(tree4, HIGH);
digitalWrite(tree5, HIGH);
// event 41
digitalWrite(tree3, LOW);
digitalWrite(tree6, LOW);
tone(pPin, 146.83); //d3
delay(e);
noTone(pPin);
digitalWrite(tree3, HIGH);
digitalWrite(tree6, HIGH);
// event 42
digitalWrite(tree4, LOW);
digitalWrite(tree5, LOW);
tone(pPin, 146.83); //d3
delay(e);
noTone(pPin);
digitalWrite(tree4, HIGH);
digitalWrite(tree5, HIGH);
// event 43
digitalWrite(tree3, LOW);
digitalWrite(tree6, LOW);
tone(pPin, 146.83); //d3
delay(75);
noTone(pPin);
digitalWrite(tree3, HIGH);
digitalWrite(tree6, HIGH);
// event 44
digitalWrite(tree2, LOW);
digitalWrite(tree7, LOW);
tone(pPin, 164.81); //e3
delay(75);
noTone(pPin);
digitalWrite(tree2, HIGH);
digitalWrite(tree7, HIGH);
// event 45
digitalWrite(tree1, LOW);
digitalWrite(tree8, LOW);
tone(pPin, 174.61); //f3
delay(dq);
noTone(pPin);
digitalWrite(tree1, HIGH);
digitalWrite(tree8, HIGH);
// event 46
digitalWrite(tree1, LOW);
digitalWrite(tree2, LOW);
digitalWrite(tree7, LOW);
digitalWrite(tree8, LOW);
tone(pPin, 164.81); //e3
delay(75);
noTone(pPin);
digitalWrite(tree1, HIGH);
digitalWrite(tree2, HIGH);
digitalWrite(tree7, HIGH);
digitalWrite(tree8, HIGH);
// event 47
digitalWrite(tree2, LOW);
digitalWrite(tree3, LOW);
digitalWrite(tree6, LOW);
digitalWrite(tree7, LOW);
tone(pPin, 146.83); //d3
delay(75);
noTone(pPin);
digitalWrite(tree2, HIGH);
digitalWrite(tree3, HIGH);
digitalWrite(tree6, HIGH);
digitalWrite(tree7, HIGH);
// event 48
digitalWrite(tree3, LOW);
digitalWrite(tree4, LOW);
digitalWrite(tree5, LOW);
digitalWrite(tree6, LOW);
tone(pPin, 130.81); //c3
delay(e);
noTone(pPin);
digitalWrite(tree3, HIGH);
digitalWrite(tree4, HIGH);
digitalWrite(tree5, HIGH);
digitalWrite(tree6, HIGH);
// event 49
digitalWrite(tree1, LOW);
digitalWrite(tree2, LOW);
digitalWrite(tree3, LOW);
digitalWrite(tree4, LOW);
digitalWrite(tree5, LOW);
digitalWrite(tree6, LOW);
digitalWrite(tree7, LOW);
digitalWrite(tree8, LOW);
tone(pPin, 261.63); //c4
delay(q);
noTone(pPin);
digitalWrite(tree1, HIGH);
digitalWrite(tree2, HIGH);
digitalWrite(tree3, HIGH);
digitalWrite(tree4, HIGH);
digitalWrite(tree5, HIGH);
digitalWrite(tree6, HIGH);
digitalWrite(tree7, HIGH);
digitalWrite(tree8, HIGH);
// event 50
digitalWrite(tree1, LOW);
digitalWrite(tree8, LOW);
tone(pPin, 220); //a3
delay(e);
noTone(pPin);
digitalWrite(tree1, HIGH);
digitalWrite(tree8, HIGH);
// event 51
digitalWrite(tree2, LOW);
digitalWrite(tree7, LOW);
tone(pPin, 196); //g3
delay(de);
noTone(pPin);
digitalWrite(tree2, HIGH);
digitalWrite(tree7, HIGH);
// event 52
digitalWrite(tree3, LOW);
digitalWrite(tree6, LOW);
tone(pPin, 174.61); //f3
delay(s);
noTone(pPin);
digitalWrite(tree3, HIGH);
digitalWrite(tree6, HIGH);
// event 53
digitalWrite(tree4, LOW);
digitalWrite(tree5, LOW);
tone(pPin, 164.81); //e3
delay(e);
noTone(pPin);
digitalWrite(tree4, HIGH);
digitalWrite(tree5, HIGH);
// event 54
digitalWrite(tree3, LOW);
digitalWrite(tree6, LOW);
tone(pPin, 174.61); //f3
delay(e);
noTone(pPin);
digitalWrite(tree3, HIGH);
digitalWrite(tree6, HIGH);
// event 55
digitalWrite(tree2, LOW);
digitalWrite(tree7, LOW);
tone(pPin, 164.81); //e3
delay(q);
noTone(pPin);
digitalWrite(tree2, HIGH);
digitalWrite(tree7, HIGH);
// event 56
digitalWrite(tree1, LOW);
digitalWrite(tree8, LOW);
tone(pPin, 146.83); //d3
delay(q);
noTone(pPin);
digitalWrite(tree1, HIGH);
digitalWrite(tree8, HIGH);
// event 57
digitalWrite(tree1, LOW);
digitalWrite(tree2, LOW);
digitalWrite(tree3, LOW);
digitalWrite(tree4, LOW);
digitalWrite(tree5, LOW);
digitalWrite(tree6, LOW);
digitalWrite(tree7, LOW);
digitalWrite(tree8, LOW);
tone(pPin, 130.81); //c3
delay(h);
noTone(pPin);
digitalWrite(tree1, HIGH);
digitalWrite(tree2, HIGH);
digitalWrite(tree3, HIGH);
digitalWrite(tree4, HIGH);
digitalWrite(tree5, HIGH);
digitalWrite(tree6, HIGH);
digitalWrite(tree7, HIGH);
digitalWrite(tree8, HIGH);
delay(1000);
}
Part 2
int noteA = 2;
int noteB = 3;
int noteC = 4;
int noteD = 5;
int noteE = 6;
int noteF = 7;
int noteG = 8;
int beat = 9;
int spkr = 10;
int w = 2500;
int h = 1250;
int q = 625;
int e = 312;
int s = 156;
int ts = 78;
int midC = 262;
int midD = 294;
int midE = 330;
int midF = 370; //sharp
int midG = 392;
int upA = 440;
int upB = 494;
int upC = 523;
int upD = 587;
int upE = 659;
int upF = 740; //sharp
int upG = 784;
void setup(){
for (int x = 2; x pinMode(x, OUTPUT);
}
}
void loop(){
for ( int x = 2; x digitalWrite(x, HIGH);
delay(e);
}
for ( int x = 2; x digitalWrite(x, LOW);
}
// measure 1
playBeat( noteD, midD, e );
play( noteB, upB, e );
play( noteA, upA, e );
play( noteG, midG, e );
playBeat( noteD, midD, q+e-10 );
delay(10);
play( noteD, midD, ts-10 );
delay(10);
play( noteD, midD, ts-10 );
delay(10);
// measure 2
playBeat( noteD, midD, e );
play( noteB, upB, e );
play( noteA, upA, e );
play( noteG, midG, e );
playBeat( noteE, midE, q+e );
delay(e);
// measure 3
playBeat( noteE, midE, e );
play( noteC, upC, e );
play( noteB, upB, e );
play( noteA, upA, e );
playBeat( noteF, midF, q+e );
delay(e);
// measure 4
playBeat( noteD, upD, e-10 );
delay(10);
play( noteD, upD, e );
play( noteC, upC, e );
play( noteA, upA, e );
digitalWrite(noteB, HIGH);
digitalWrite(beat, HIGH);
tone(spkr, upB, q);
delay(q);
digitalWrite(beat, LOW);
digitalWrite(noteG, HIGH);
tone(spkr, midG);
delay(q);
digitalWrite(noteB, LOW);
digitalWrite(noteG, LOW);
noTone(spkr);
// measure 5
playBeat(noteD, midD, e );
play( noteB, upB, e );
play( noteA, upA, e );
play( noteG, midG, e );
playBeat( noteD, midD, q+e );
delay(e);
// measure 6
playBeat( noteD, midD, e );
play( noteB, upB, e );
play( noteA, upA, e );
play( noteG, midG, e );
playBeat( noteE, midE, q+e-10 );
delay(10);
play( noteE, midE, e-10 );
delay(10);
// measure 7
playBeat( noteE, midE, e );
play( noteC, upC, e );
play( noteB, upB, e );
play( noteA, upA, e );
playBeat( noteD, upD, e-10 );
delay(10);
play( noteD, upD, e-10 );
delay(10);
play( noteD, upD, e-10 );
delay(10);
play( noteD, upD, e );
// measure 8
playBeat( noteE, upE, e );
play( noteD, upD, e );
play( noteC, upC, e );
play( noteA, upA, e );
playBeat( noteG, midG, q+e );
delay(e);
// measure 9
playBeat( noteB, upB, e-10 );
delay(10);
play( noteB, upB, e-10 );
delay(10);
play( noteB, upB, q-10 );
delay(10);
playBeat( noteB, upB, e-10 );
delay(10);
play( noteB, upB, e-10 );
delay(10);
play( noteB, upB, q-10 );
delay(10);
// measure 10
playBeat( noteB, upB, e );
play( noteD, upD, e );
play( noteG, midG, e+s );
play( noteA, upA, s );
playBeat( noteB, upB, q+e );
delay(e);
// measure 11
playBeat( noteC, upC, e-10 );
delay(10);
play( noteC, upC, e-10 );
delay(10);
play( noteC, upC, e+s-10 );
delay(10);
play( noteC, upC, s-10 );
delay(10);
playBeat( noteC, upC, e );
play( noteB, upB, e-10 );
delay(10);
play( noteB, upB, e-10 );
delay(10);
play( noteB, upB, s-10 );
delay(10);
play( noteB, upB, s-10 );
delay(10);
// measure 12
playBeat( noteB, upB, e );
play( noteA, upA, e-10 );
delay(10);
play( noteA, upA, e );
play( noteB, upB, e );
playBeat( noteA, upA, q );
play( noteD, upD, q );
// measure 13
playBeat( noteB, upB, e-10 );
delay(10);
play( noteB, upB, e-10 );
delay(10);
play( noteB, upB, q-10 );
delay(10);
playBeat( noteB, upB, e-10 );
delay(10);
play( noteB, upB, e-10 );
delay(10);
play( noteB, upB, q-10 );
delay(10);
// measure 14
playBeat( noteB, upB, e );
play( noteD, upD, e );
play( noteG, midG, e+s );
play( noteA, upA, s );
playBeat( noteB, upB, q+e );
delay(e);
// measure 15
playBeat( noteC, upC, e-10 );
delay(10);
play( noteC, upC, e-10 );
delay(10);
play( noteC, upC, e+s-10 );
delay(10);
play( noteC, upC, s-10 );
delay(10);
playBeat( noteC, upC, e );
play( noteB, upB, e-10 );
delay(10);
play( noteB, upB, e-10 );
delay(10);
play( noteB, upB, s-10 );
delay(10);
play( noteB, upB, s );
// measure 16
playBeat( noteD, upD, e-10 );
delay(10);
play( noteD, upD, e );
play( noteC, upC, e );
play( noteA, upA, e );
playBeat( noteG, midG, q+e );
}
void play(int light, int note, int length ){
digitalWrite( light, HIGH );
tone( spkr, note );
delay( length );
digitalWrite( light, LOW );
noTone( spkr );
}
void playBeat(int light, int note, int length ){
digitalWrite( light, HIGH );
digitalWrite( beat, HIGH);
tone( spkr, note );
delay( length );
digitalWrite( light, LOW );
digitalWrite( beat, LOW );
noTone( spkr );
}
4 years ago
Hi, I have a question that need your expertise.
When I upload the code for the Automatic Blinking Light, the lights on the relays are not at the steady state like how you demo in the video. It is constantly in flickering state and somewhat respond to the music.
After re-downloading FHT libraries didn't help.
Question 4 years ago on Step 6
Can I use LED lights with this project?
5 years ago
What kind of serial outputs should be showing up on the monitor? Mine is acting intermittently.
5 years ago
Hello @RoboAvatar! Thanx for sharing your project! I choose it to experiments with my students! but we are a bit confused on how to connect all together Relays + Electrical Micro w/Arduino and how to start it 'cuz ours doesn't work.