Author Topic: Axon II button not being recognized?  (Read 1468 times)

0 Members and 1 Guest are viewing this topic.

Offline Hero ITopic starter

  • Jr. Member
  • **
  • Posts: 31
  • Helpful? 0
Axon II button not being recognized?
« 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;
}

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
Re: Axon II button not being recognized?
« Reply #1 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
« Last Edit: October 15, 2014, 12:07:07 PM by Webbot »
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline Hero ITopic starter

  • Jr. Member
  • **
  • Posts: 31
  • Helpful? 0
Re: Axon II button not being recognized?
« Reply #2 on: October 17, 2014, 02:18:51 PM »
The above solution worked.


 


Get Your Ad Here