Hello, so I'm creating a little puzzle using 8 fuse switches (RCD).
The correct pattern of switches need to be set to activate a lock release (in this case (Down, Up,Down,Up,Down, Down, Down, Up)
Having issue with the error mesagge
"Arduino: 1.8.12 (Mac OS X), Board: "Arduino Uno"
Buttontest23:61:1: error: expected unqualified-id before 'else'
else {
^~~~
Buttontest23:67:1: error: expected declaration before '}' token
}
^
exit status 1
expected unqualified-id before 'else'
"
Below is my code;
const int greenLED = 10;
const int redLED = 11;
void setup() {
//start serial connection
Serial.begin(9600);
//configure pin 2 as an input and enable the internal pull-up resistor
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
pinMode(13, INPUT_PULLUP);
pinMode(12, INPUT_PULLUP);
pinMode(greenLED, OUTPUT);
digitalWrite(greenLED, LOW);
digitalWrite(redLED, HIGH);
}
void loop() {
//read the pushbutton value into a variable
int fuse1 = digitalRead(2);
int fuse2 = digitalRead(3);
int fuse3 = digitalRead(4);
int fuse4 = digitalRead(5);
int fuse5 = digitalRead(6);
int fuse6 = digitalRead(7);
int fuse7 = digitalRead(13);
int fuse8 = digitalRead(12);
//print out the value of the fuse
Serial.print(fuse1);
Serial.print(fuse2);
Serial.print(fuse3);
Serial.print(fuse4);
Serial.print(fuse5);
Serial.print(fuse6);
Serial.print(fuse7);
Serial.print(fuse8);
Serial.println(F(" CODE ENTERED"));
delay (1000);
if ((digitalRead(fuse1) == 1 && digitalRead(fuse2) == 0 && digitalRead(fuse3) == 1 && digitalRead(fuse4) == 0 && digitalRead(fuse5) == 1 && digitalRead(fuse6) == 1 && digitalRead(fuse7) == 1 && digitalRead(fuse8) == 0));
digitalWrite(greenLED, HIGH); // turn the Green LED ON
digitalWrite(redLED, LOW); // turn the RED LED OFF
Serial.println(F("PUZZLE COMPLETE"));
delay (5000);
}
else {
digitalWrite(greenLED, LOW); // turn the Green LED OFF
digitalWrite(redLED, HIGH); // turn the RED LED ON
Serial.println(F("PUZZLE INCOMPLETE"));
delay (1000);
}
}
}
Any help is appreciated.