Society of Robots - Robot Forum

Software => Software => Topic started by: Hero I on October 14, 2014, 10:43:47 PM

Title: Axon II button not being recognized?
Post by: Hero I on October 14, 2014, 10:43:47 PM
I'm using WLS 1-14 and Axon II and I can't get the push button to work on the Axon II.

Below is the my code and you can see that every second I'm outputting "Hello World!" to the standard out which does exactly that.

However, when I press the button on the Axon II, it's not recognizing any action because I'm not getting any of the output that is programmed in any of the "if" statements.

Does anybody know what my problem might be?

Code: [Select]
TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart)
{
TICK_COUNT delta, now;
static TICK_COUNT last = 0;

now = clockGetus();
delta = now - last;
if (delta > 1000000) // 1.0 second
{
cout << "Hello World!\n";
last = now;
}

if (button.isPressed())
{
cout << "Pressed\n";
}

if (button.isReleased())
{
cout << "Released\n";
}

if (button.isDepressed())
{
cout << "Depressed\n";
}

if (button.isWorking())
{
cout << "Working\n";
}

if (button.isChanged())
{
cout << "Changed\n";
}

return 0;
}
Title: Re: Axon II button not being recognized?
Post by: Webbot on October 15, 2014, 11:41:20 AM
All input devices, sensors etc need to be read before you start checking their values.
So to fix your code then just add  a single 'button.read();' near the top of your function - before any 'button.isXXXX()'  calls. All of the isXXXX calls then compare the last read with the previous one.

Also your 'now = clockGetus();' could just be 'now=loopStart;'

[edited] to fix typos!

[edited again to add the following] Assuming you've generated the help files.... then in Studio go to Help|Documentation/AVR8 and in the browser page type 'switch' into the search box and selected 'Switch webbot'
You'll then see help on all the commands
Title: Re: Axon II button not being recognized?
Post by: Hero I on October 17, 2014, 02:18:51 PM
The above solution worked.