I was trying to write code for a lightning effect for Halloween. I got an"'else' without a previous 'if'" error message even though "if" is above. My code is below:
int TriggerValue = 0;
void setup() {
// put your setup code here, to run once:
pinMode(A0, INPUT);//Botton trigger
pinMode(1, OUTPUT);// light
pinMode(2, OUTPUT); //sfx
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
TriggerValue = digitalRead(A0);
if (TriggerValue != 0)
Serial.println("Triggered");
digitalWrite(1, HIGH);
delay(200);
digitalWrite(1, LOW);
digitalWrite(2, HIGH);
delay(200);
Serial.println("Gottom! You should have seen the look on your face!");
digitalWrite(2, LOW);
else
(TriggerValue != 1);
digitalWrite(1, LOW);
}
`
Thank you for helping!