go_away

Author Topic: A couple of embarrassing Axon2/WebBotLib questions.  (Read 1133 times)

0 Members and 1 Guest are viewing this topic.

Offline KelpyTopic starter

  • Full Member
  • ***
  • Posts: 82
  • Helpful? 0
A couple of embarrassing Axon2/WebBotLib questions.
« on: October 20, 2010, 10:10:16 AM »
Can someone please tell me what code I need to put in to make my robot wait for me to press the button on the Axon2 before it starts?

Also, what code do I need to put in to turn an LED on and off connected to ADC9 (5V REG)?

Thank you.

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,132
  • Helpful? 108
Re: A couple of embarrassing Axon2/WebBotLib questions.
« Reply #1 on: October 20, 2010, 01:59:32 PM »
Suggest you try using Project Designer downloadable from my site http://webbot.org.uk/iPoint/37.page

It will allow you to add an LED to whichever pin (the button is already there since its built in)

Then generate the code and look at the generated example code.
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 KelpyTopic starter

  • Full Member
  • ***
  • Posts: 82
  • Helpful? 0
Re: A couple of embarrassing Axon2/WebBotLib questions.
« Reply #2 on: October 21, 2010, 01:57:03 AM »
Thanks, Webbot, I can now control my external LED's. (I love the designer BTW)

But, how do I set the controller not to start running the program until I press the button.
I can see this code, but I don't understand how it works. In anycase my bot starts the programme as soon as it is switched on at the battery.
Code: [Select]
// -------- Start Switch/Button-------
// Switch/Button - see switch.h

// To test if it is pressed then
if(SWITCH_pressed(&button)){
// pressed
}

// To test if it is released then
if(SWITCH_released(&button)){
// released
}
// -------- End   Switch/Button-------

Thanks.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,657
  • Helpful? 169
    • Society of Robots
Re: A couple of embarrassing Axon2/WebBotLib questions.
« Reply #3 on: October 21, 2010, 08:00:12 AM »
Just have it sit in a while loop:

while(!SWITCH_pressed(&button));

Offline KelpyTopic starter

  • Full Member
  • ***
  • Posts: 82
  • Helpful? 0
Re: A couple of embarrassing Axon2/WebBotLib questions.
« Reply #4 on: October 21, 2010, 08:48:40 AM »
Thanks, Admin, I'll try and do that.

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,132
  • Helpful? 108
Re: A couple of embarrassing Axon2/WebBotLib questions.
« Reply #5 on: October 21, 2010, 04:47:29 PM »
while(!SWITCH_pressed(&button));

But put that code in the appInitSoftware function rather than appControl - otherwise you will need to press the button every time around your main loop
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 KelpyTopic starter

  • Full Member
  • ***
  • Posts: 82
  • Helpful? 0
Re: A couple of embarrassing Axon2/WebBotLib questions.
« Reply #6 on: October 22, 2010, 08:33:28 AM »
Thanks, Webbot. I haven't had time to try it yet - this weekend.

Amazingly, I actually thought about that - must be learning something :)

 


Get Your Ad Here

data_list