Hi,
does anybody know how to fix this?
Error codes:
Final_test_code:125: error: expected unqualified-id before 'if'
if (sstopPOS == LOW && power == 0){ // If sstop is pressed
^
Final_test_code:129: error: expected unqualified-id before 'if'
if (sstopmode == 1 && resetPOS == LOW){ // If sstop is engaged and reset button is pressed
^
Final_test_code:133: error: expected unqualified-id before 'if'
if (estopPOS == LOW){ // If Estop is pressed
^
Final_test_code:139: error: expected unqualified-id before 'if'
if (estopPOS == HIGH && resetPOS == LOW){ // If estop is up and reset is pushed
^
Final_test_code:145: error: expected unqualified-id before 'if'
if (endofdayPOS == LOW){ // If endofdayestop is pressed down
^
Final_test_code:147: error: expected unqualified-id before 'if'
if (endofdayPOS == HIGH){ // if endofdayestop is off
^
Final_test_code:155: error: expected unqualified-id before 'if'
if (switch1POS == LOW && power == 0 && sstopmode == 0){ // If switch 1 is pressed
^
Final_test_code:161: error: expected unqualified-id before 'if'
if (switch2POS == LOW && power == 0 && sstopmode == 0){ // If switch 2 is pressed
^
Final_test_code:167: error: expected unqualified-id before 'if'
if (switch2POS == LOW && power == 0 && sstopmode == 0){ // If switch 3 is pressed
^
Final_test_code:173: error: expected unqualified-id before 'if'
if (switch2POS == LOW && power == 0 && sstopmode == 0){ // If switch 4 is pressed
^
exit status 1
expected unqualified-id before 'if'
My code:
//Set Pin Values for buttons
const int endofday = 1;
const int reset = 2;
const int switch1 = 3;
const int switch2 = 4;
const int switch3 = 5;
const int switch4 = 6;
const int sstop = 7;
const int preshow = 8;
const int estop = 9;
const int gates = 10;
const int restraintsOPEN = 11;
const int restraintsCLOSED = 12;
const int tilt = 13;
const int stationselect = 14;
const int launch = 15;
const int dispatch = 16;
// Variable states
int sstopmode = 0; // station stop is off
int power = 0; // Power disconnect is off
void setup(){
// Pin modes
pinMode(endofday, INPUT_PULLUP);
pinMode(reset, INPUT_PULLUP);
pinMode(switch1, INPUT_PULLUP);
pinMode(switch2, INPUT_PULLUP);
pinMode(switch3, INPUT_PULLUP);
pinMode(switch4, INPUT_PULLUP);
pinMode(sstop, INPUT_PULLUP);
pinMode(preshow, INPUT_PULLUP);
pinMode(estop, INPUT_PULLUP);
pinMode(gates, INPUT_PULLUP);
pinMode(restraintsOPEN, INPUT_PULLUP);
pinMode(restraintsCLOSED, INPUT_PULLUP);
pinMode(tilt, INPUT_PULLUP);
pinMode(stationselect, INPUT_PULLUP);
pinMode(launch, INPUT_PULLUP);
pinMode(dispatch, INPUT_PULLUP);}
void loop() {
// Set variables for button states
int endofdayPOS = digitalRead(endofday);
int resetPOS = digitalRead(reset);
int switch1POS = digitalRead(switch1);
int switch2POS = digitalRead(switch2);
int switch3POS = digitalRead(switch3);
int switch4POS = digitalRead(switch4);
int sstopPOS = digitalRead(sstop);
int preshowPOS = digitalRead(preshow);
int estopPOS = digitalRead(estop);
int gatesPOS = digitalRead(gates);
int tiltPOS = digitalRead(tilt);
int selectorPOS = digitalRead(stationselect);
int launchPOS = digitalRead(launch);
int dispatchPOS = digitalRead(dispatch);
// |------------------------------------------------------------------------------|
// |===============================Station Controls===============================|
// |------------------------------------------------------------------------------|
//Launch Button
if (launchPOS == LOW && power == 0 && sstopmode == 0){ // If launch is pressed
Keyboard.press('l'); // Press L
delay (300);
Keyboard.releaseAll();}
// Dispatch Button
if (dispatchPOS == LOW && power == 0 && sstopmode == 0){ // If dispatch is pressed
Keyboard.press(' '); // Press spacebar
delay (300);
Keyboard.releaseAll();}
// Tilt Button
if (tiltPOS == LOW && power == 0 && sstopmode == 0){ // If tilt is pressed
Keyboard.press(KEY_RETURN); // Press enter for 4 seconds
delay (4000);
Keyboard.releaseAll();}
//Preshow doors/start
if (preshowPOS == LOW && power == 0 && sstopmode == 0){ // If preshow is pressed
Keyboard.press(KEY_RETURN); // press return
delay (100);
Keyboard.releaseAll();}
//Gates
if (gates == LOW){
Keyboard.press(KEY_LEFT_ARROW);
delay (100);
Keyboard.releaseAll();}
else{
Keyboard.press(KEY_RIGHT_ARROW);
delay (100);
Keyboard.releaseAll();}
}
//Restraints
//Selector
// |------------------------------------------------------------------------------|
// |===============================Stop Controls==================================|
// |------------------------------------------------------------------------------|
// Station Stop Button
if (sstopPOS == LOW && power == 0){ // If sstop is pressed
sstopmode = 1;} // Set sstop mode to 1 (On)
// Station Stop Reset
if (sstopmode == 1 && resetPOS == LOW){ // If sstop is engaged and reset button is pressed
sstopmode = 0;} // Turn sstop to 0 (off)
// Estop button
if (estopPOS == LOW){ // If Estop is pressed
Keyboard.press('s'); // Press S
delay(100);
Keyboard.releaseAll();}
//Reset Estop
if (estopPOS == HIGH && resetPOS == LOW){ // If estop is up and reset is pushed
Keyboard.press('r'); // press R
delay(100);
Keyboard.releaseAll();}
// End Of Day
if (endofdayPOS == LOW){ // If endofdayestop is pressed down
power = 1;} // Panel disable is on
if (endofdayPOS == HIGH){ // if endofdayestop is off
power = 0;} // Panel disable is off
// |--------------------------------------------------------------------------------------|
// |===============================Maintainance Controls==================================|
// |--------------------------------------------------------------------------------------|
// Switch 1
if (switch1POS == LOW && power == 0 && sstopmode == 0){ // If switch 1 is pressed
Keyboard.press('1'); // Press 1
delay (100);
Keyboard.releaseAll();}
// Switch 2
if (switch2POS == LOW && power == 0 && sstopmode == 0){ // If switch 2 is pressed
Keyboard.press('2'); // Press 2
delay (100);
Keyboard.releaseAll();}
// Switch 3
if (switch2POS == LOW && power == 0 && sstopmode == 0){ // If switch 3 is pressed
Keyboard.press('3'); // Press 3
delay (100);
Keyboard.releaseAll();}
//Switch 4
if (switch2POS == LOW && power == 0 && sstopmode == 0){ // If switch 4 is pressed
Keyboard.press('4'); // Press 4
delay (100);
Keyboard.releaseAll();}
Thanks!