Arduino Christmas Light Controller

287,257

466

118

Published

Introduction: Arduino Christmas Light Controller

If you liked this instructable, consider checking out my new website www.TheSiliconJunkie.com

You've probably seen all those videos where people make there christmas lights dance to music, you think to your self wow that looks realy cool.... i could never do that. WELL... you can the idea is actually quite simple.
WHATS A RELAY?
a relay is a component that can be used to control large amounts of voltage or current with just a small voltage, it does this by using that small voltage (5 volts in our case) to create a magnetic feild that will pull a switch type object to connect the larger current (120 volts in our case). Image 2 is a diagram on how a relay works





Step 1: Supplies

• 1x Arduino
• 1x Protoshield/ breadboard
8x 5v DC relays »»»  search.digikey.com/scripts/DkSearch/dksus.dll
• 8x 1N4004 diodes »»» search.digikey.com/scripts/DkSearch/dksus.dll
• 8x 2N2222 transistors »»» search.digikey.com/scripts/DkSearch/dksus.dll
• 8x 1K (Brown,Black,Red) ohm resistor (radio shack)
• 1x double/single sided PCB (radioshack)
• 1x sharpie
• 16x nuts and bolts (discuss size later)
• 8x dead sets of lights (for there male plugs)
• 500 ft of 5 strand cable
• a set of connector things
• some wire and some other stuff that you should have
• a place to display your light show
• and a some what knowledge of making pcb's

LETS BEGIN SHALL WE


Step 2:

Once you have all your parts i started out by testing one relay on a bread board
1. Put all the components in acourding to the scematic (image 1)
2. Open the arduino program and goto open>digital>Blink
3. Upload it to your arduino
4. Connect where it says arduino pin on the schematic to digital pin 13

if all works well then its time to multiply that by 8 on a pcb

Step 3: Making the PCB

sorry this step isnt to detailed because i forgot to take pictures but heres my best

BRAIN STORM:
I started by jotting down some idea patterns on some paper heres what i came up with (image 1)

DRILL THE HOLES:
then i placed each component on the pcb and marked it on the pcb. Then i drilled all the holes
IMPORTANT: KEEP IN MIND WHICH SIDE HAS THE COMPONENTS ON IT AND WHICH SIDE HAS THE TRACES

CONNECT THE DOTS:
Once all the holes are drilled it just a simple game of connect the dots. Do this with your sharpie it must be a "Sharpie" sharpie not some no name brand because i tested 3 types of markers 2 no names and the sharpie, the no namers ink bubbled up during the etching process (not a good thing). Also make sure to color in the lines dark, and your 5 volt and GND traces a little thicker than the others.

ETCHING TIME:
Once you are done drawing your lines and are satisfied with it. Get a tuperware bowl and some etchant solution and etch your board, keeping an eye on it so it doesnt over etch. When its done take it out and clean off all the excess acid and use some nail polish remover or rubbing alcohol to clean off all the sharpie.

SOLDER IN THE COMPONENTS:
Before i started soldering i took some 800 grit sand paper and sanded down the copper a little so it was clean, that way the solder sticks to it alot better. Now just place the components and solder them in one at a time. (image 2)

WIRING:
I chose to use a "weaving" method to reduce tension on the solder joints, which so far has seemed to work great. (image 3,4)

Step 4: Wire Up Your Display

For my display i chose these 8 trees in my yard. (image 1) You can pick what ever you want as long as the arduino can somehow be inside and warm. For me the best option was to put him in the garage. I went to home depot and bought some 5 strand sprinkler wire cause it was on sale for $24 for 500ft. (image 2). Since your setup probable woulnt be the same as mine ill just show you how wire on each plug.

1) Get 8 dead christmass lights and cut off the female plug (image 4)
2) Get all the supplies in image 5
3) Layout the cable the way you want it
4) Find where your gonna put the plug to connect the tree into and using the knife cut open the casing
5) Pull out the ground (for me its WHITE) and cut it in half, strip both ends and connect both sides of the ground to one wire on the plug using a crimp connector.
6) Do the same thing for the colored wire which is the power coming into the tree. (image 6)
7) Tape up the connectors nicely (image 7)
8) Fold the wires nicely against the cable and tape it again (image 8)

Once done it should look like image 9. Now just do that to all the trees.

Step 5: Bringing It All Together

Once all the plugs are connected and you have every going to where it needs to be, we need to connect each tree to the pcb.

1) i used some wire from the dead lights to connect all the positives on the pcb (image 1)
2) get the crimp connectors and connect some onto the wires coming from the trees like (image 2) leave the white be for now
3) connect those wires to the pcb in the correct order
4) i took an old exstention cord and cut the cord off and connected one end to the 120v input on the pcb and the other to the 2 whites
5) lastly connect the arduino up to the pcb (image 3)
6) tape up those connection and store it somewhere safe
7) upload the Joy To The World code, and see if it works. if so GREAT!!!! if not, not good. if you cant figure out the problem post a comment and ill try my best at helping you.

Joy To The World code:

int tree1 = 6;
int tree2 = 7;
int tree3 = 8;
int tree4 = 9;
int tree5 = 2;
int tree6 = 3;
int tree7 = 4;
int tree8 = 5;
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 start;
int end;
int time;

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,HIGH);
  delay(1000);
  digitalWrite(tree2,HIGH);
  delay(1000);
  digitalWrite(tree3,HIGH);
  delay(1000);
  digitalWrite(tree4,HIGH);
  delay(1000);
  digitalWrite(tree5,HIGH);
  delay(1000);
  digitalWrite(tree6,HIGH);
  delay(1000);
  digitalWrite(tree7,HIGH);
  delay(1000);
  digitalWrite(tree8,HIGH);
  delay(1000);
  digitalWrite(tree1,LOW);
  digitalWrite(tree2,LOW);
  digitalWrite(tree3,LOW);
  digitalWrite(tree4,LOW);
  digitalWrite(tree5,LOW);
  digitalWrite(tree6,LOW);
  digitalWrite(tree7,LOW);
  digitalWrite(tree8,LOW);
  Serial.begin(9600);
}

void loop()
{
  start = millis();
  digitalWrite(tree1, HIGH);
  digitalWrite(tree8, HIGH);
  delay(q);
  digitalWrite(tree1, LOW);
  digitalWrite(tree8, LOW);

  digitalWrite(tree2, HIGH);
  digitalWrite(tree7, HIGH);
  delay(de);
  digitalWrite(tree2, LOW);
  digitalWrite(tree7, LOW);

  digitalWrite(tree3, HIGH);
  digitalWrite(tree6, HIGH);
  delay(s);
  digitalWrite(tree3, LOW);
  digitalWrite(tree6, LOW);

  digitalWrite(tree4, HIGH);
  digitalWrite(tree5, HIGH);
  delay(1050);
  digitalWrite(tree4, LOW);
  digitalWrite(tree5, LOW);

  digitalWrite(tree1, HIGH);
  digitalWrite(tree8, HIGH);
  delay(s);
  digitalWrite(tree1, LOW);
  digitalWrite(tree8, LOW);

  digitalWrite(tree2, HIGH);
  digitalWrite(tree7, HIGH);
  delay(q);
  digitalWrite(tree2, LOW);
  digitalWrite(tree7, LOW);

  digitalWrite(tree3, HIGH);
  digitalWrite(tree6, HIGH);
  delay(q);
  digitalWrite(tree3, LOW);
  digitalWrite(tree6, LOW);

  digitalWrite(tree4, HIGH);
  digitalWrite(tree5, HIGH);
  delay(dq);
  digitalWrite(tree4, LOW);
  digitalWrite(tree5, LOW);

  digitalWrite(tree1, HIGH);
  digitalWrite(tree2, HIGH);
  digitalWrite(tree7, HIGH);
  digitalWrite(tree8, HIGH);
  delay(e);
  digitalWrite(tree1, LOW);
  digitalWrite(tree2, LOW);
  digitalWrite(tree7, LOW);
  digitalWrite(tree8, LOW);

  digitalWrite(tree2, HIGH);
  digitalWrite(tree3, HIGH);
  digitalWrite(tree6, HIGH);
  digitalWrite(tree7, HIGH);
  delay(dq);
  digitalWrite(tree2, LOW);
  digitalWrite(tree3, LOW);
  digitalWrite(tree6, LOW);
  digitalWrite(tree7, LOW);

  digitalWrite(tree1, HIGH);
  digitalWrite(tree2, HIGH);
  digitalWrite(tree7, HIGH);
  digitalWrite(tree8, HIGH);
  delay(e);
  digitalWrite(tree1, LOW);
  digitalWrite(tree2, LOW);
  digitalWrite(tree7, LOW);
  digitalWrite(tree8, LOW);

  digitalWrite(tree3, HIGH);
  digitalWrite(tree4, HIGH);
  digitalWrite(tree5, HIGH);
  digitalWrite(tree6, HIGH);
  delay(dq);
  digitalWrite(tree3, LOW);
  digitalWrite(tree4, LOW);
  digitalWrite(tree5, LOW);
  digitalWrite(tree6, LOW);

  digitalWrite(tree1, HIGH);
  digitalWrite(tree2, HIGH);
  digitalWrite(tree7, HIGH);
  digitalWrite(tree8, HIGH);
  delay(e);
  digitalWrite(tree1, LOW);
  digitalWrite(tree2, LOW);
  digitalWrite(tree7, LOW);
  digitalWrite(tree8, LOW);

  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(dq);
  digitalWrite(tree1, LOW);
  digitalWrite(tree2, LOW);
  digitalWrite(tree3, LOW);
  digitalWrite(tree4, LOW);
  digitalWrite(tree5, LOW);
  digitalWrite(tree6, LOW);
  digitalWrite(tree7, LOW);
  digitalWrite(tree8, LOW);

  digitalWrite(tree8, HIGH);
  delay(e);
  digitalWrite(tree8, LOW);

  digitalWrite(tree1, HIGH);
  delay(e);
  digitalWrite(tree1, LOW);

  digitalWrite(tree7, HIGH);
  delay(e);
  digitalWrite(tree7, LOW);  

  digitalWrite(tree2, HIGH);
  delay(e);
  digitalWrite(tree2, LOW);

  digitalWrite(tree6, HIGH);
  delay(e);
  digitalWrite(tree6, LOW);

  digitalWrite(tree3, HIGH);
  delay(de);
  digitalWrite(tree3, LOW);

  digitalWrite(tree5, HIGH);
  delay(s);
  digitalWrite(tree5, LOW);
 
  digitalWrite(tree4, HIGH);
  delay(e);
  digitalWrite(tree4, LOW);
 
  digitalWrite(tree8, HIGH);
  delay(e);
  digitalWrite(tree8, LOW);

  digitalWrite(tree1, HIGH);
  delay(e);
  digitalWrite(tree1, LOW);

  digitalWrite(tree7, HIGH);
  delay(e);
  digitalWrite(tree7, LOW);  

  digitalWrite(tree2, HIGH);
  delay(e);
  digitalWrite(tree2, LOW);

  digitalWrite(tree6, HIGH);
  delay(e);
  digitalWrite(tree6, LOW);

  digitalWrite(tree3, HIGH);
  delay(de);
  digitalWrite(tree3, LOW);

  digitalWrite(tree5, HIGH);
  delay(s);
  digitalWrite(tree5, LOW);
 
  digitalWrite(tree4, HIGH);
  delay(e);
  digitalWrite(tree4, LOW);
 
  digitalWrite(tree2, HIGH);
  digitalWrite(tree7, HIGH);
  delay(e);
  digitalWrite(tree2, LOW);
  digitalWrite(tree7, LOW);
 
  digitalWrite(tree1, HIGH);
  digitalWrite(tree8, HIGH);
  delay(e);
  digitalWrite(tree1, LOW);
  digitalWrite(tree8, LOW);
 
  digitalWrite(tree2, HIGH);
  digitalWrite(tree7, HIGH);
  delay(e);
  digitalWrite(tree2, LOW);
  digitalWrite(tree7, LOW);
 
  digitalWrite(tree1, HIGH);
  digitalWrite(tree8, HIGH);
  delay(e);
  digitalWrite(tree1, LOW);
  digitalWrite(tree8, LOW);
 
  digitalWrite(tree2, HIGH);
  digitalWrite(tree7, HIGH);
  delay(75);
  digitalWrite(tree2, LOW);
  digitalWrite(tree7, LOW);
 
  digitalWrite(tree3, HIGH);
  digitalWrite(tree6, HIGH);
  delay(75);
  digitalWrite(tree3, LOW);
  digitalWrite(tree6, LOW);
 
  digitalWrite(tree4, HIGH);
  digitalWrite(tree5, HIGH);
  delay(dq);
  digitalWrite(tree4, LOW);
  digitalWrite(tree5, LOW);
 
  digitalWrite(tree4, HIGH);
  digitalWrite(tree5, HIGH);
  delay(75);
  digitalWrite(tree4, LOW);
  digitalWrite(tree5, LOW);
 
  digitalWrite(tree3, HIGH);
  digitalWrite(tree6, HIGH);
  delay(75);
  digitalWrite(tree3, LOW);
  digitalWrite(tree6, LOW);
 
  digitalWrite(tree4, HIGH);
  digitalWrite(tree5, HIGH);
  delay(e);
  digitalWrite(tree4, LOW);
  digitalWrite(tree5, LOW);
 
  digitalWrite(tree3, HIGH);
  digitalWrite(tree6, HIGH);
  delay(e);
  digitalWrite(tree3, LOW);
  digitalWrite(tree6, LOW);
 
  digitalWrite(tree4, HIGH);
  digitalWrite(tree5, HIGH);
  delay(e);
  digitalWrite(tree4, LOW);
  digitalWrite(tree5, LOW);
 
  digitalWrite(tree3, HIGH);
  digitalWrite(tree6, HIGH);
  delay(75);
  digitalWrite(tree3, LOW);
  digitalWrite(tree6, LOW);
 
  digitalWrite(tree2, HIGH);
  digitalWrite(tree7, HIGH);
  delay(75);
  digitalWrite(tree2, LOW);
  digitalWrite(tree7, LOW);
 
  digitalWrite(tree1, HIGH);
  digitalWrite(tree8, HIGH);
  delay(dq);
  digitalWrite(tree1, LOW);
  digitalWrite(tree8, LOW);
 
  digitalWrite(tree1, HIGH);
  digitalWrite(tree2, HIGH);
  digitalWrite(tree7, HIGH);
  digitalWrite(tree8, HIGH);
  delay(75);
  digitalWrite(tree1, LOW);
  digitalWrite(tree2, LOW);
  digitalWrite(tree7, LOW);
  digitalWrite(tree8, LOW);
 
  digitalWrite(tree2, HIGH);
  digitalWrite(tree3, HIGH);
  digitalWrite(tree6, HIGH);
  digitalWrite(tree7, HIGH);
  delay(75);
  digitalWrite(tree2, LOW);
  digitalWrite(tree3, LOW);
  digitalWrite(tree6, LOW);
  digitalWrite(tree7, LOW);
 
  digitalWrite(tree3, HIGH);
  digitalWrite(tree4, HIGH);
  digitalWrite(tree5, HIGH);
  digitalWrite(tree6, HIGH);
  delay(e);
  digitalWrite(tree3, LOW);
  digitalWrite(tree4, LOW);
  digitalWrite(tree5, LOW);
  digitalWrite(tree6, LOW);
 
  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(q);
  digitalWrite(tree1, LOW);
  digitalWrite(tree2, LOW);
  digitalWrite(tree3, LOW);
  digitalWrite(tree4, LOW);
  digitalWrite(tree5, LOW);
  digitalWrite(tree6, LOW);
  digitalWrite(tree7, LOW);
  digitalWrite(tree8, LOW);
 
  digitalWrite(tree1, HIGH);
  digitalWrite(tree8, HIGH);
  delay(e);
  digitalWrite(tree1, LOW);
  digitalWrite(tree8, LOW);
 
  digitalWrite(tree2, HIGH);
  digitalWrite(tree7, HIGH);
  delay(de);
  digitalWrite(tree2, LOW);
  digitalWrite(tree7, LOW);
 
  digitalWrite(tree3, HIGH);
  digitalWrite(tree6, HIGH);
  delay(s);
  digitalWrite(tree3, LOW);
  digitalWrite(tree6, LOW);
 
  digitalWrite(tree4, HIGH);
  digitalWrite(tree5, HIGH);
  delay(e);
  digitalWrite(tree4, LOW);
  digitalWrite(tree5, LOW);
 
  digitalWrite(tree3, HIGH);
  digitalWrite(tree6, HIGH);
  delay(e);
  digitalWrite(tree3, LOW);
  digitalWrite(tree6, LOW);
 
  digitalWrite(tree2, HIGH);
  digitalWrite(tree7, HIGH);
  delay(q);
  digitalWrite(tree2, LOW);
  digitalWrite(tree7, LOW);
 
  digitalWrite(tree1, HIGH);
  digitalWrite(tree8, HIGH);
  delay(q);
  digitalWrite(tree1, LOW);
  digitalWrite(tree8, LOW);
 
  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(h);
  digitalWrite(tree1, LOW);
  digitalWrite(tree2, LOW);
  digitalWrite(tree3, LOW);
  digitalWrite(tree4, LOW);
  digitalWrite(tree5, LOW);
  digitalWrite(tree6, LOW);
  digitalWrite(tree7, LOW);
  digitalWrite(tree8, LOW);
  delay(20000);
 
  end = millis();
  time = end - start;
  Serial.println(time);
}








Arduino Contest

Finalist in the
Arduino Contest

Share

    Recommendations

    • Water Contest

      Water Contest
    • Clocks Contest

      Clocks Contest
    • Oil Contest

      Oil Contest

    118 Discussions

    Actually, I just wrote this for Jingle Bells. I added a speaker to play the music, and wrote it into functions to cut the size down.

    Chris H

    ***copy below this line and paste directly into a new Sketch****

    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 < 11; x++) {
    pinMode(x, OUTPUT);
    }
    }

    void loop(){
    for ( int x = 2; x < 10; x++) {
    digitalWrite(x, HIGH);
    delay(e);
    }

    for ( int x = 2; x < 10; 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 replies

    I made it working fine.

    can you please tell how to write the codes of other songs

    I copied it from sheet music I found for free online. Just match the notes to the different notes and durations.

    I have made it and working fine. Can you please give some idea how to add more songs.or if you have codes for any other songs please post

    Forgive me for restarting and old post, but can someone explain to me why you need the transistor? Cant you simply use a SSR with 5v coil attached to each pin on the Arduino? Im not really sure what transistors add to an electrical circuit.

    Any newer versions of this simple setup out there?

    You can, but you'll need a 12v power source to run them. Be careful to keep the 12v separate from the 5v on the Arduino. The 2N2222s are configured in open-collector, so they will switch the 12v easily.

    So.... I have the controller working through a headphone output and would really like to tap into my speakers on my porch. I'm a bit hesitant to hookup the speaker output into the Arduino. Not really keen on what the different "levels" are. What is it that I need?

    Got all my supplies. How do you wire up the Arduino? There's not really an explanation here or I missed something.

    I made a Christmas light controller similar to this one. But, I have a mp3 shield ready to use (and my music file too). I have been looking everywhere for a piece of coding to make it start and stop at the beginning and at the end of the code. Any one have the piece of coding I need? Thanks!

    1 reply

    what shield do you have? I'm looking for a compatible shield

    0
    user
    RKSBOT

    1 year ago

    Dear Dany, Can I use simple 2N2222 black coloured transistor?

    2 replies

    Can I use this transistor?

    temp_1334843929.jpg

    Yes you can. They are the same transistor in two different packages. The one he uses in this project has a TO-39 package. The one you want to use it a TO-92. :)

    Thanks in advance

    ok you create the sequencing on vixen, but you need to connect serial? or vixen give you the delay points to arduino code? I don´t understand how you did it!!!, please let me know, thanks!!!