/* LED Pentagram - all blink to off Keep Music Evil Turns on an LED on for one second, then off for one second, repeatedly. I am connecting a LilyPad Arduino to 5 LilyPad 3-color LED's using pins 2, 5, 9, 12, and 13 Created 12 July 2010 By Ryan Raffa */ int ledPins[5] = {5,6,9,10,11}; // LED connected to digital pins 2,5,9, 12,13 int state[6] = {3000, 6000, 9000, 12000, 15000, 18000}; //determines when to change pins int stateCounter = 0; // I use these to run through the ledPins int changePin = 2; //check this pin to see if it should do option A or B int buttonState = 0; //value of changePin int newState = 0; int newStateCounter = 0; int fadeValue; int i; void setup() { // initialize the digital pin as an output: for (i = 0; i < 5; i++) { pinMode(ledPins[i], OUTPUT); } pinMode(changePin, INPUT); // For troubleshooting, I use Serial.print to check on statecounter // Serial.begin(9600); } void loop() { if (newStateCounter <= 10) { for(fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) { analogWrite(ledPins[0], fadeValue); analogWrite(ledPins[1], fadeValue); analogWrite(ledPins[2], fadeValue); analogWrite(ledPins[3], fadeValue); analogWrite(ledPins[4], fadeValue); delay(30); } for(fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) { analogWrite(ledPins[0], fadeValue); analogWrite(ledPins[1], fadeValue); analogWrite(ledPins[2], fadeValue); analogWrite(ledPins[3], fadeValue); analogWrite(ledPins[4], fadeValue); delay(30); } } if (newStateCounter > 10) { digitalWrite(ledPins[0], LOW); digitalWrite(ledPins[1], LOW); digitalWrite(ledPins[2], LOW); digitalWrite(ledPins[3], LOW); digitalWrite(ledPins[4], LOW); delay(10000); } newStateCounter++; // i know it's bad to let the counter run until infinity, but it was crunch time // i'll do a better job of keeping track of that in the future }