T-Shirt Timer by Ellen Abnee and Ashley Sanchez

on

Non Blinking Circuit 

Blinking Circuit 


Arduino Codes

Arduino 1 – The Blinking Lights (the timer lights)
//Pin Definitions
//Pin Definitions
//The 74HC595 uses a serial communication 
//link which has three pins
int data = 2; 
int clock = 3;
int latch = 4;
int data2 = 11; 
int clock2 = 12;
int latch2 = 13;
//Used for single LED manipulation
int ledState = 0;
const int ON = HIGH;
const int OFF = LOW;
int ledState2 = 0;
const int ON2 = HIGH;
const int OFF2 = LOW;                        
/*
 * setup() – this function runs once when you turn your Arduino on
 * We set the three control pins to outputs
 */
void setup()
{
  pinMode(data, OUTPUT);
  pinMode(clock, OUTPUT);  
  pinMode(latch, OUTPUT);  
  pinMode(data2, OUTPUT);
  pinMode(clock2, OUTPUT);  
  pinMode(latch2, OUTPUT); 
}
/*
 * loop() – this function will start after setup finishes and then repeat
 * we set which LEDs we want on then call a routine which sends the states to the 74HC595
 */
void loop()                     // run over and over again
{
  int delayTime = 5000; //the number of milliseconds to delay between LED updates
  int delayTime2 = 10000; //the number of milliseconds to delay between LED updates
  for(int i = 0; i < 6; i++){
    for(int y = 0; y < 6; y++){
      changeLED(i, 1);
      changeLED2(y, 1);
      delay(delayTime2);
      changeLED(i, 0);
      changeLED2(y, 0);
    }               // wait for a second  
  }
}
// run over and over again
//{
//  int delayTime2 = 1000; //the number of milliseconds to delay between LED updates
//  for(int y = 0; y < 8; y++){
//   changeLED2(y, 1);
//   delay(delayTime2);
//  changeLED2(y, 0);
//  }
//}
/*
 * updateLEDs() – sends the LED states set in ledStates to the 74HC595
 * sequence
 */
void updateLEDs(int value){
  digitalWrite(latch, LOW);     //Pulls the chips latch low
  shiftOut(data, clock, MSBFIRST, value); //Shifts out the 8 bits to the shift register
  digitalWrite(latch, HIGH);   //Pulls the latch high displaying the data
}
/*
 * updateLEDs() – sends the LED states set in ledStates to the 74HC595
 * sequence
 */
void updateLEDs2(int value2){
  digitalWrite(latch2, LOW);     //Pulls the chips latch low
  shiftOut(data2, clock2, MSBFIRST, value2); //Shifts out the 8 bits to the shift register
  digitalWrite(latch2, HIGH);   //Pulls the latch high displaying the data
}
//These are used in the bitwise math that we use to change individual LEDs
int bits[] = {
  B00000001, B00000010, B00000100, B00001000, B00010000, B00100000};
int masks[] = {
  B11111110, B11111101, B11111011, B11110111, B11101111, B11011111};
int bits2[] = {
  B00000001, B00000010, B00000100, B00001000, B00010000, B00100000};
int masks2[] = {
  B11111110, B11111101, B11111011, B11110111, B11101111, B11011111};
/*
 * changeLED(int led, int state) – changes an individual LED 
 * LEDs are 0 to 7 and state is either 0 – OFF or 1 – ON
 */
void changeLED(int led, int state){
  ledState = ledState & masks[led];  //clears ledState of the bit we are addressing
  if(state == ON){
    ledState = ledState | bits[led];
  } //if the bit is on we will add it to le
  //dState
  updateLEDs(ledState);              //send the new LED state to the shift register
}
void changeLED2(int led2, int state2){
  ledState2 = ledState2 & masks2[led2];  //clears ledState of the bit we are addressing
  if(state2 == ON){
    ledState2 = ledState2 | bits2[led2];
  } //if the bit is on we will add it to le
  //dState
  updateLEDs2(ledState2);              //send the new LED state to the shift register
}

Arduino 2 –  The Constant Lights (the lights that don’t blink at all)
/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.
 
  This example code is in the public domain.
 */
 
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led1 = 13;
int led2 = 12;
int led3= 11;
int led4 = 10;
int led5 = 9;
int led6 = 8;
int led7 = 7;
int led8 = 6;
int led9 = 5;
int led10 = 4;
int led11= 3;
int led12= 2;
// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led4, OUTPUT);
  pinMode(led5, OUTPUT);
  pinMode(led6, OUTPUT);
  pinMode(led7, OUTPUT);
  pinMode(led8, OUTPUT);
  pinMode(led9, OUTPUT);
  pinMode(led10, OUTPUT);
  pinMode(led11, OUTPUT);
  pinMode(led12, OUTPUT);
  
}
// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led1, HIGH);             
  digitalWrite(led2, HIGH);   
   digitalWrite(led3, HIGH); 
   digitalWrite(led4, HIGH); 
   digitalWrite(led5, HIGH); 
   digitalWrite(led6, HIGH); 
   digitalWrite(led7, HIGH); 
   digitalWrite(led8, HIGH); 
   digitalWrite(led9, HIGH); 
   digitalWrite(led10, HIGH); 
   digitalWrite(led11, HIGH); 
   digitalWrite(led12, HIGH);   // turn the LED on (HIGH is the voltage level)
}