Hi !
I have tried to build an Mode/Function selection with use of the Moba Tools,
Function 1 and Function 2 works fine, Function 3 works sort of, when i let go the off second push the Function 3 lets go and switches to function 1.
So it would be better to let an Desired angle value, set by ( Function 1 joystick ) or ( Function 2 compass ) to controll the stepper1.write( " Desierd angle"); ?
Best Regards
Andreas
}
void loop() {
myButtons.processButtons();
if ( myButtons.longPress(0) ) {
// button pressed long -> set referencepoint
Serial.println( "Set referencepoint" );
Function = 1;
}
if ( myButtons.shortPress(0) ) {
// button pressed short -> return stepper to refrencepoint
Serial.println( "Return to refrencepoint" );
Function = 2;
}
// button pressed twice short-> Activate function that lets the compass reading refrence set the angle of steper.
if ( myButtons.pressed(0)) {
releaseIndex = 1 - releaseIndex;
releaseTimes[releaseIndex] = millis();
if (abs(releaseTimes[0] - releaseTimes[1]) < 800) {
releaseTimes[0] = 0;
releaseTimes[1] = 0;
laserIndex = 1 - laserIndex;
Function = 3;
}
}
Serial.println (Function);
}