controlling stepper motor with rotary sensor/limit switch/button

Arduino: 1.8.10 (Windows 10), Board: “Arduino/Genuino Uno”

C:\Users\WYI\Documents\Arduino\controlling_stepper_motor_with_rotary_sensor2\controlling_stepper_motor_with_rotary_sensor2.ino: In function ‘void loop()’:

C:\Users\WYI\Documents\Arduino\controlling_stepper_motor_with_rotary_sensor2\controlling_stepper_motor_with_rotary_sensor2.ino:84:10: warning: return-statement with a value, in function returning ‘void’ [-fpermissive]

return isPress;

^~~~~~~

controlling_stepper_motor_with_rotary_sensor2:88:6: error: expected initializer before ‘bool’

bool isPress = false;

^~~~

C:\Users\WYI\Documents\Arduino\controlling_stepper_motor_with_rotary_sensor2\controlling_stepper_motor_with_rotary_sensor2.ino:108:10: warning: return-statement with a value, in function returning ‘void’ [-fpermissive]

return isPress;

^~~~~~~

C:\Users\WYI\Documents\Arduino\controlling_stepper_motor_with_rotary_sensor2\controlling_stepper_motor_with_rotary_sensor2.ino: At global scope:

controlling_stepper_motor_with_rotary_sensor2:111:5: error: expected unqualified-id before ‘else’

else if( leftSw == LOW && (digitalRead(dirPin) == HIGH) ){

^~~~

controlling_stepper_motor_with_rotary_sensor2:115:5: error: expected unqualified-id before ‘else’

else if( rightSw == LOW && (digitalRead(dirPin) == LOW ) ){

^~~~

}

^

exit status 1
expected initializer before ‘bool’

This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.

New Text Document.txt (3.79 KB)

Where does the loop() function end ?
Somewhere before the start of the p2ButtonPress() I imagine

  bool isPress = false

Something important missing

or (p1buttonState != lastp1buttonState);

What is this ?

    return isPress;

The loop() function is declared void so why try to return a value and where do you suppose that it is being returned to ?