Jon and Tim's Light Show

Tim Vincent and Jon Groszek

Description
  • For our project, we created a crazy cool light show using led's of course. But what we did was we used 6 led's and instead of using 6 pins, we used 3 pins on the arduino board. So in the end we have a total of 24 led's connected to a total of 12 pins. We soon figured out that it would be much easier and much shorter of a code if we used arrays to assign the pins. Now let's take a look at our code:

 int pos[] = {2,3,3,4,2,4,6,7,7,8,8,6,10,11,11,12,10,12,5,9,9,13,5,13};
 int neg[] = {3,2,4,2,4,3,7,6,8,7,6,8,11,10,12,11,12,10,9,5,13,5,13,9};
 int ondelay = 100;

void setup()                                                         //no setup
 {
 }

void on (int ondelay) //All led's on
{  
  for (int t = 0; t<=ondelay; t++)
   {
   for(int x = 0;x<=24; x++)
  {
  pinMode (pos[x],OUTPUT);
  pinMode (neg[x],OUTPUT);
  digitalWrite (pos[x], HIGH);
  digitalWrite (neg[x], LOW);
  delayMicroseconds (100);
  pinMode (pos[x],INPUT);
  pinMode (neg[x],INPUT); 
  }
  }
}

void seq (int Speed)    // runs through the led's in sequence
{  
   for(int x = 0;x<=24; x++)
  {
  pinMode (pos[x],OUTPUT);
  pinMode (neg[x],OUTPUT);
  digitalWrite (pos[x], HIGH);
  digitalWrite (neg[x], LOW);
  delay (Speed);
  pinMode (pos[x],INPUT);
  pinMode (neg[x],INPUT); 
  }

}

void on1 (int ondelay)    //lights up the whole first column
{  
  for (int t = 0; t<=ondelay; t++)
   {
   for(int x = 0;x<=5; x++)
  {
  pinMode (pos[x],OUTPUT);
  pinMode (neg[x],OUTPUT);
  digitalWrite (pos[x], HIGH);
  digitalWrite (neg[x], LOW);
  delayMicroseconds (100);
  pinMode (pos[x],INPUT);
  pinMode (neg[x],INPUT); 
  }
  }
}

 
void loop()
 {
 
   seq(500);
   on(400);

   delay (500);
  
   on1(1000);
  
   for (int t = 0; t<=500; t++)
   {
   for(int x = 6;x<=12; x++)  //runs through 2nd and 3rd columns side by side
  {
  pinMode (pos[x],OUTPUT);
  pinMode (neg[x],OUTPUT);
  pinMode (pos[x+6],OUTPUT);
  pinMode (neg[x+6],OUTPUT);
  digitalWrite (pos[x], HIGH);
  digitalWrite (neg[x], LOW);
  digitalWrite (pos[x+6], HIGH);
  digitalWrite (neg[x+6], LOW);
  delayMicroseconds (100);
  pinMode (pos[x],INPUT);
  pinMode (neg[x],INPUT); 
  pinMode (pos[x+6],INPUT);
  pinMode (neg[x+6],INPUT); 
  }
   }

   for(int x = 0;x<=5; x++)  //runs through first columns
  {
  pinMode (pos[x],OUTPUT);
  pinMode (neg[x],OUTPUT);
  pinMode (pos[x+5],OUTPUT);
  pinMode (neg[x+5],OUTPUT);
  digitalWrite (pos[x], HIGH);
  digitalWrite (neg[x], LOW);
  digitalWrite (pos[x+5], HIGH);
  digitalWrite (neg[x+5], LOW);
  delay (100);
  pinMode (pos[x],INPUT);
  pinMode (neg[x],INPUT); 
  pinMode (pos[x+5],INPUT);
  pinMode (neg[x+5],INPUT); 
  }


 }

Procedure
After we got the code all figured out with the leds in the breadboard, we lined up leds in a square along the edge of a 3" by 3" piece of perfboard. Then Tim found a clear plastic case from an ipod and we cut that to 3" by 3" so that we could put the piece of perfboard with the leds inside the plastic case. Next, we decided that we weren't going to use a breadboard because it's kind of big and bulky and we really didn't need it. Then we soldered wires to the pins that we were using on the arduino board and also soldered resistors to the wires. What we did next is a little confusing. We took a piece of wire and soldered each side to both of the leds connected to pin 2. Then we did the same thing for pin 3 and pin 4 and so on.

Comments