Friday, May 11, 2012

WE HAVE A PROJECT!!

After playing around with the code and some confusing and frustrating times, we now have everything working!

There are some timing kinks that I don't really know how to fix and I don't know if I will figure it out. The IR sensor isn't very reliable but it gets the job done.

Here is a video of the working piece:


And the code:


//array of power and ground pins for specific color LEDs
//white
int pxlArray[4] = {0,2,4,6};
int gndArray[4] = {7,9,11,13};

//red
int predArray[4] = {0,2,4,6};
int gredArray[3] = {8,10,12};

//green
int pgreenArray[3] = {1,3,5};
int ggreenArray[4] = {7,9,11,13};

//blue
int pblueArray[3] = {1,3,5};
int gblueArray[3] = {8,10,12};

//array of power and ground pins for LEDs
int pallArray[7] = {0,1,2,3,4,5,6};
int gallArray[7] = {7,8,9,10,11,12,13};


//randomizing integers
int pxlRandom;
int gndRandom;

//sensor data
int irSensor = A0;
int irSensorData = 0;
int irSensorMap = 0;

void setup () {
 

  //make array of LED pins outputs
  for(int ii = 0; ii < 4; ii++) {
    pinMode(pxlArray[ii], OUTPUT);
    pinMode(gndArray[ii], OUTPUT);
    pinMode(predArray[ii], OUTPUT);
    pinMode(gredArray[ii], OUTPUT);
    pinMode(pgreenArray[ii], OUTPUT);
    pinMode(ggreenArray[ii], OUTPUT);
    pinMode(pblueArray[ii], OUTPUT);
    pinMode(gblueArray[ii], OUTPUT);
    pinMode(pallArray[ii], OUTPUT);
    pinMode(gallArray[ii], OUTPUT);
  }

  //make A0 pin an input for IR sensor
  pinMode(irSensor, INPUT);

}

void loop () {
   //set irSensorData and irSensorMap value
  irSensorData = analogRead(irSensor);
  irSensorMap = map(irSensorData, 0, 1023, 0, 18);

  //if statements
  if(irSensorMap == 0) {
    pxlRandom = random(0,3);
    gndRandom = random(0,4);

    for (int aa = 0; aa < 750; aa++) {
    digitalWrite(pblueArray[pxlRandom], HIGH);
    digitalWrite(gblueArray[gndRandom], HIGH);
    delay(1);
    digitalWrite(pblueArray[pxlRandom], LOW);
    digitalWrite(gblueArray[gndRandom], LOW);
    delay(0);
    digitalWrite(predArray[pxlRandom], HIGH);
    digitalWrite(gredArray[gndRandom], HIGH);
    delay(1);
    digitalWrite(predArray[pxlRandom], LOW);
    digitalWrite(gredArray[gndRandom], LOW);
    delay(0);
    }
    analogRead(irSensor);
    delay(250);
 
  }

  if(irSensorMap == 1) {
    pxlRandom = random(0,3);
    gndRandom = random(0,4);

    for (int aa = 0; aa < 500; aa++) {
    digitalWrite(pblueArray[pxlRandom], HIGH);
    digitalWrite(gblueArray[gndRandom], HIGH);
    delay(1);
    digitalWrite(pblueArray[pxlRandom], LOW);
    digitalWrite(gblueArray[gndRandom], LOW);
    delay(0);
    digitalWrite(pxlArray[pxlRandom], HIGH);
    digitalWrite(gndArray[gndRandom], HIGH);
    delay(1);
    digitalWrite(pxlArray[pxlRandom], LOW);
    digitalWrite(gndArray[gndRandom], LOW);
    delay(0);
    }
    analogRead(irSensor);
 
    delay(200);
  }

  if(irSensorMap == 2) {
    pxlRandom = random(0,3);
    gndRandom = random(0,4);

    for (int aa = 0; aa < 250; aa++) {
    digitalWrite(pgreenArray[pxlRandom], HIGH);
    digitalWrite(ggreenArray[gndRandom], HIGH);
    delay(1);
    digitalWrite(pgreenArray[pxlRandom], LOW);
    digitalWrite(ggreenArray[gndRandom], LOW);
    delay(0);
    digitalWrite(pxlArray[pxlRandom], HIGH);
    digitalWrite(gndArray[gndRandom], HIGH);
    delay(1);
    digitalWrite(pxlArray[pxlRandom], LOW);
    digitalWrite(gndArray[gndRandom], LOW);
    delay(0);
    }
    analogRead(irSensor);
    delay(100);
  }

  if(irSensorMap == 3) {
    pxlRandom = random(0,4);
    gndRandom = random(0,4);

    for (int aa = 0; aa < 50; aa++) {
    digitalWrite(pgreenArray[pxlRandom], HIGH);
    digitalWrite(ggreenArray[gndRandom], HIGH);
    delay(1);
    digitalWrite(pgreenArray[pxlRandom], LOW);
    digitalWrite(ggreenArray[gndRandom], LOW);
    delay(0);
    digitalWrite(predArray[pxlRandom], HIGH);
    digitalWrite(gredArray[gndRandom], HIGH);
    delay(1);
    digitalWrite(predArray[pxlRandom], LOW);
    digitalWrite(gredArray[gndRandom], LOW);
    delay(0);
    }
    analogRead(irSensor);
 
    delay(50);
  }

  if(irSensorMap == 4) {
    pxlRandom = random(0,4);
    gndRandom = random(0,4);

    for (int aa = 0; aa < 10; aa++) {
    digitalWrite(predArray[pxlRandom], HIGH);
    digitalWrite(gredArray[gndRandom], HIGH);
    delay(1);
    digitalWrite(predArray[pxlRandom], LOW);
    digitalWrite(gredArray[gndRandom], LOW);
    delay(0);
    digitalWrite(pxlArray[pxlRandom], HIGH);
    digitalWrite(gndArray[gndRandom], HIGH);
    delay(1);
    digitalWrite(pxlArray[pxlRandom], LOW);
    digitalWrite(gndArray[gndRandom], LOW);
    delay(0);
    }
    analogRead(irSensor);
 
    delay(10);
  }

  if(irSensorMap == 5) {
    pxlRandom = random(0,4);
    gndRandom = random(0,4);

    for (int aa = 0; aa < 10; aa++) {
    digitalWrite(predArray[pxlRandom], HIGH);
    digitalWrite(gredArray[gndRandom], HIGH);
    delay(1);
    digitalWrite(predArray[pxlRandom], LOW);
    digitalWrite(gredArray[gndRandom], LOW);
    delay(0);
    digitalWrite(pxlArray[pxlRandom], HIGH);
    digitalWrite(gndArray[gndRandom], HIGH);
    delay(1);
    digitalWrite(pxlArray[pxlRandom], LOW);
    digitalWrite(gndArray[gndRandom], LOW);
    delay(0);
    }
    analogRead(irSensor);
 
    delay(10);
  }

  if(irSensorMap >= 6) {
    //PARTY!
       for(int cc = 0; cc < 10; cc++) {
        for (int aa = 6; aa > -1; aa--) {
          for(int bb = 0; bb < 7; bb++) {
            digitalWrite(pallArray[aa], HIGH);
            digitalWrite(gallArray[bb], HIGH);
            delay(2);
            digitalWrite(pallArray[aa], LOW);
            digitalWrite(gallArray[bb], LOW);
            delay(0);
            digitalWrite(pallArray[bb], HIGH);
            digitalWrite(gallArray[aa], HIGH);
            delay(2);
            digitalWrite(pallArray[bb], LOW);
            digitalWrite(gallArray[aa], LOW);
            delay(0);
          }
        }
      }
    for(int cc = 0; cc < 10; cc++) {
       for (int aa = 0; aa < 7; aa++) {
         for(int bb = 0; bb < 7; bb++) {
            digitalWrite(pallArray[aa], HIGH);
            digitalWrite(gallArray[bb], HIGH);
            delay(2);
            digitalWrite(pallArray[aa], LOW);
            digitalWrite(gallArray[bb], LOW);
            delay(0);
            digitalWrite(pallArray[bb], HIGH);
            digitalWrite(gallArray[aa], HIGH);
            delay(2);
            digitalWrite(pallArray[bb], LOW);
            digitalWrite(gallArray[aa], LOW);
            delay(0);
          }
        }
      }
    analogRead(irSensor);
  }

}

Thursday, May 10, 2012

Problems

Attached the sensor to the bottom of our canvas .
Had to re-solder some cables.

Running into coding problems today.
We can't seem to separate LEDS from one another in the process.
So we are still investigating how to mux.


Possible solution is to program it to run with activity rather than on color sequencing.

Tuesday, May 8, 2012

Making Lots of Progress

Kara soldering the last of the Ground Wires
View from the back, Our Complete Circuit

Attaching Power to Arduino

Diego soldering the Connecting Positive and Negative Cables

First LED Activity!

 
First Random Test

Programming Script

 
Huzzah! 

We decided to go with the cheaper smaller version. We already purchased a 10"x10" canvas where we will place the LEDs. Now we're going to wait to get the rest of the components but here is a picture that I drew about it along with a diagram that shows the colors.

I wish we could have made something bigger but I think it will look really good!

Diego



Thursday, May 3, 2012

Randomizing!

I was able to figure out how to randomize the mux! Here is a video:




And the code:

int pwrArray[4] = {4,3,2};
int gndArray[4] = {5,6,7};
int pwrRandom;
int gndRandom;

void setup () {
  
  for(int ii = 0; ii < 3; ii++) {
    pinMode(pwrArray[ii], OUTPUT);
    pinMode(gndArray[ii], OUTPUT);
  }
  Serial.begin(9600);
  randomSeed (0);
}

void loop () {
  
  pwrRandom = random (0,3);
  gndRandom = random (0,3);
  
  digitalWrite(pwrArray[pwrRandom], HIGH);
  digitalWrite(gndArray[gndRandom], HIGH);
  
  Serial.print (pwrRandom);
  Serial.println(gndRandom);
  
  delay (100);
  
  digitalWrite(pwrArray[pwrRandom], LOW);
  digitalWrite(gndArray[gndRandom], LOW);
}
  

Tuesday, May 1, 2012





Puncturing the Canvas to put LEDS in, using one LED to fit the holes correctly.

Tuesday, April 24, 2012

Number Crunching

Today we spent most of the day cost comparing the peggy board against building our own "peggy" board and doing a evaluation to see which would be the most economical for us.

Buying the Peggy Board
Peggy Board: $95.00
LEDS (625count) : $131.00
D Cell Batteries: $7.00
FTDICable: $17.00
Sensor: $15.00
Total Cost: $265.00

Builidng our Own
Arudino: $34.99
Mux Shield: $25.00
Sensor: $15.00
LEDS (200): $63.60
Transistors: $12.35
Board: $10.00
Total Cost: $160.94

Building our own but smaller (if we use the capacity of the arduino, we will save $25 on not buying a mux shield, save money on the amount of leds , and on the amount of transistors we need)

Arudino: $34.99
Sensor: $15.00
LEDs (60): $45.60
Transistors(7):$6.65
Board: $10.00
Total Cost: $105.59

Kara: (Sparkfun.com $67.20+shipping)
Diego (Arduino and casing materials $34.99+)