Some LED lights a push button and a tilt switch,

heres some code to go with the circuit.

int led = 6; // the pin that the LED1 is attached to int led2 = 9; // the pin that the LED2 is attached to int led3 = 10; // the pin that the LED2 is attached to int led4 = 11; // the pin that the LED2 is attached to int pushButton = 7; int tiltButton = 8; int brightness = 0; // how bright the LED is int fadeAmount = 5; // how many points to fade the LED by boolean usePushButton; boolean useTiltButton; int counter;

// the setup routine runs once when you press reset: void setup() {

// declare pin 9 to be an output: pinMode(led, OUTPUT); pinMode(led2, OUTPUT); pinMode(led3, OUTPUT); pinMode(led4, OUTPUT); Serial.begin(9600); }

void sillyLEDBlinkingPattern() { int someDelay = 300; digitalWrite(led, HIGH); delay(someDelay); digitalWrite(led, LOW);

digitalWrite(led2, HIGH); delay(someDelay);
digitalWrite(led2, LOW);

digitalWrite(led3, HIGH); delay(someDelay);
digitalWrite(led3, LOW);

digitalWrite(led4, HIGH); delay(someDelay);
digitalWrite(led4, LOW);

delay(someDelay); digitalWrite(led4, HIGH); digitalWrite(led3, HIGH); digitalWrite(led2, HIGH); digitalWrite(led, HIGH); delay(someDelay); digitalWrite(led4, LOW); digitalWrite(led3, LOW); digitalWrite(led2, LOW); digitalWrite(led, LOW); }

// the loop routine runs over and over again forever: void loop() { //Serial.begin(9600); //Serial.println(digitalRead(pushButton)); int sensorValue = analogRead(8); Serial.println(sensorValue);

if(counter == 0){ // make a silly LED blinking pattern sillyLEDBlinkingPattern(); }

if(digitalRead(pushButton) == LOW && usePushButton == true){ Serial.println("push button was pressed"); counter++; usePushButton = false; } if(digitalRead(pushButton) == HIGH){ Serial.println("push button is not pressed"); usePushButton = true; }

if(digitalRead(tiltButton) == LOW){ counter = 0; }

if(counter == 1){ analogWrite(led, brightness); } else { digitalWrite(led, LOW); } if(counter == 2){ analogWrite(led2, brightness); } else { digitalWrite(led2, LOW); } if(counter == 3){ analogWrite(led3, brightness); } else { digitalWrite(led3, LOW); } if(counter == 4){ analogWrite(led4, brightness); } else { digitalWrite(led4, LOW); } if(counter > 4){ counter = 0; }

// change the brightness for next time through the loop: brightness = brightness + fadeAmount;

// reverse the direction of the fading at the ends of the fade: if (brightness == 0 || brightness == 255) { fadeAmount = -fadeAmount ; }
// wait for 10 milliseconds to see the dimming effect
delay(10);
}