Society of Robots - Robot Forum
Software => Software => Topic started 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.
-
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.
-
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.
// -------- 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.
-
Just have it sit in a while loop:
while(!SWITCH_pressed(&button));
-
Thanks, Admin, I'll try and do that.
-
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
-
Thanks, Webbot. I haven't had time to try it yet - this weekend.
Amazingly, I actually thought about that - must be learning something :)