I am getting this error. Any idea? It doesnt make sense to add another } at the end
Beam_break_sensor_new1:170: error: expected '}' at end of input
//Diesels High Tech Pet beam break sensor
//This sketch activates and deactivates the "hold Up" function which is build into the HIGH TECH pet door
//By imitating pressing and holding "ON BUTTON" while pressing "OPEN BUTTON" and then releasing both buttons
enum State {
IDLE, PAUSE_BEFORE_ON, ON_DELAY, OPEN_DELAY, WAIT_BEAM, PAUSE_BEFORE_CLOSE, OFF_DELAY
} state = IDLE;
uint32_t start_time;
const uint32_t PAUSE_BEFORE_ON_ms = 10L * 1000L; //pause for 10 seconds before initiating sequence
const uint32_t ON_DELAY_ms = 500L; // pause for half a second before sending ON signal
const uint32_t OPEN_DELAY_ms = 500L; // pause for half a second before sending OPEN signal
const uint32_t PAUSE_BEFORE_CLOSE_ms = 2L * 1000L; // pause for 2 seconds before sending ground signal to openPin which deactivates "hold Up" function
const uint32_t OFF_DELAY_ms = 250L;// pause for quarter of a second
const boolean SNEAK = true;
const uint32_t SNEAK_TIME = 3000L;// Time to get out the door
const byte onPin = 2; // On button
const byte openPin = 3; // Open button
const byte beamPin = 4; // QT50CM yellow wire of receiver
void activateButton(byte pin) {
// to activate a button, we ground the pin
pinMode(pin, OUTPUT);
digitalWrite(pin, LOW);
}
void deactivateButton(byte pin) {
// to deactivate a button, we float the pin
pinMode(pin, INPUT);
digitalWrite(pin, LOW);
}
void setup() {
deactivateButton(onPin);
deactivateButton(openPin);
pinMode(beamPin, INPUT_PULLUP); // turn on internal 5.1k pullup resistor
state = IDLE;
start_time = millis();
}
boolean beamIsBroken() {
//'broken beam' grounds the output
return digitalRead(beamPin) == LOW;
}
/**
--wait for beam to break (IDLE)
--beam breaks
--wait 10 seconds (PAUSE_BEFORE_ON)
--send signal to ON
--wait half a second (ON_DELAY)
--send signal to OPEN
--wait half a second (OPEN_DELAY)
--release/turn off/float both signals
--wait for beam to reconnect (WAIT_BEAM)
--wait another 2 seconds (PAUSE_BEFORE_CLOSE)
--send ground signal to ON(which deactivates function)
--wait 1/4 of a second (OFF_DELAY)
--turn off "hold Up funtion" by sending ground signal to openPin
--wait for beam to break again (IDLE)
*/
void loop() {
/**If the beam is broke, wait three seconds
Then check if the beam is still broke.
If so, set SNEAK false, otherwise keep it true **/
if ( beamIsBroken() && state == IDLE ) {
delay(SNEAK_TIME);
if (beamIsBroken()) {
SNEAK == false;
} else {
SNEAK == true;
}//close if/else
}//close if
switch (state) {
case IDLE:
if (SNEAK == false) {
state = PAUSE_BEFORE_ON;
start_time = millis();
SNEAK == false;
}
break;
switch (state) {
case IDLE:
if (beamIsBroken()) {
state = PAUSE_BEFORE_ON;
start_time = millis();
}
break;
case PAUSE_BEFORE_ON:
if (millis() - start_time >= PAUSE_BEFORE_ON_ms) {
activateButton(onPin);
state = ON_DELAY;
start_time = millis();
}
break;
case ON_DELAY:
if (millis() - start_time >= ON_DELAY_ms) {
activateButton(openPin);
state = OPEN_DELAY;
start_time = millis();
}
break;
case OPEN_DELAY:
if (millis() - start_time >= OPEN_DELAY_ms) {
deactivateButton(openPin);
deactivateButton(onPin);
state = WAIT_BEAM;
start_time = millis();
}
break;
case WAIT_BEAM:
if (!beamIsBroken()) {
state = PAUSE_BEFORE_CLOSE;
start_time = millis();
}
break;
case PAUSE_BEFORE_CLOSE:
if (beamIsBroken()) {
state = WAIT_BEAM;
start_time = millis();
}
else if (millis() - start_time >= PAUSE_BEFORE_CLOSE_ms) {
activateButton(openPin);
state = OFF_DELAY;
start_time = millis();
}
break;
case OFF_DELAY:
if (millis() - start_time >= OFF_DELAY_ms) {
deactivateButton(openPin);
state = IDLE;
start_time = millis();
}
break;
}
}