so i changes a few numbers and a few signs and i have the light going in reverse to the program in the book but the light are dim and the tilt switch has no effect now.
const int switchPin = 8;
unsigned long previousTime = 0;
int switchState = 0;
int previousSwitchState = 0;
int led = 7;
long interval = 500;
void setup() {
for(int x = 7;x>8;x--){
pinMode(x, OUTPUT);
}
pinMode(switchPin, INPUT);
}
void loop() {
unsigned long currentTime = millis();
if(currentTime - previousTime > interval) {
previousTime = currentTime;
digitalWrite(led, HIGH);
led--;
if(led == 2) {
}
}
switchState = digitalRead(switchPin);
if(switchState != previousSwitchState){
for(int x = 2; x>8;x--){
digitalWrite(x, LOW);
}
led = 7;
previousTime = currentTime;
}
(previousSwitchState = switchState);
}
Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Also post the original code so we can see where you made the changes.