Society of Robots - Robot Forum

Software => Software => Topic started by: Kelpy on October 20, 2010, 10:10:16 AM

Title: A couple of embarrassing Axon2/WebBotLib questions.
Post by: Kelpy 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.
Title: Re: A couple of embarrassing Axon2/WebBotLib questions.
Post by: Webbot 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 (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.
Title: Re: A couple of embarrassing Axon2/WebBotLib questions.
Post by: Kelpy 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.
Title: Re: A couple of embarrassing Axon2/WebBotLib questions.
Post by: Admin on October 21, 2010, 08:00:12 AM
Just have it sit in a while loop:

while(!SWITCH_pressed(&button));
Title: Re: A couple of embarrassing Axon2/WebBotLib questions.
Post by: Kelpy on October 21, 2010, 08:48:40 AM
Thanks, Admin, I'll try and do that.
Title: Re: A couple of embarrassing Axon2/WebBotLib questions.
Post by: Webbot 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
Title: Re: A couple of embarrassing Axon2/WebBotLib questions.
Post by: Kelpy 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 :)