Hello,
I have been slowly progressing in getting the axon II to do different things. I was able to use a pot input to control a modified servo, and thought a reasonable next step would be to figure out how to use the pushbutton on the Axon. Basically, I want it to switch directions when the button is pressed.
I am using Webbotlib and Project Designer. The program compiles with 0 errors and warnings, but when upload it to the controller the servo runs in one direction only, and the switch doesnt appear to do anything.
Code:
#include "hardware.h"
bool val = true;
// Initialise the hardware
void appInitHardware(void) {
initHardware();
}
// Initialise the software
TICK_COUNT appInitSoftware(TICK_COUNT loopStart){
return 0;
}
// This is the main loop
TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart) {
if(button.pressed()){
val = (!val);
}
if((val = true)){
servo.setSpeed(DRIVE_SPEED_MIN);
}
if((val = false)){
servo.setSpeed(DRIVE_SPEED_MAX);
}
return 0;
}
I also tried a nested loop that was changing the direction when I would press the button, but on release it would cause it to revert. This would work maybe until I held the button down for a few seconds then it would run in reverse and not change.
I know this is probably something really dumb.