Hello.
I’m (as you might understand) new to this kind of controllers. I’ve used Picaxe until now. But found them to be less good when using them mainly to controll servos…
I’m using the sample script from the tutorial to have the Controller move 3 servos when I close a switch on channel 23. This is working fine. But I want to have more switches (at least 3 more) and for each different switch I want a new “scenario” to take place. For example: Switch 1 (channel23) moves 3 servos to a given postion for 5 seconds and then back. Switch 2 (channel22) moves 1 on the 3 servos to a given postion for 10 seconds.
I do understand how to set up the movement, timing and so on. But I dont know how to get the controller to go to the different subroutines when the different switches are pressed.
Here is a link to my project: agathashus.se
Regards, Lars
begin
4000 4000 4000 frame_1
5000 5000 5000 frame_1
6000 6000 6000 frame_1
7000 7000 7000 frame_1
repeat
sub frame_1
wait_for_button_press
2 servo 0 servo 1 servo
return
sub button
23 get_position 500 less_than
return
# Waits for a button press, with debouncing.
# (Requires the BUTTON subroutine.)
sub wait_for_button_press
wait_for_button_open_10ms
wait_for_button_closed_10ms
return
# wait for the button to be NOT pressed for at least 10 ms
sub wait_for_button_open_10ms
get_ms # put the current time on the stack
begin
# reset the time on the stack if it is pressed
button
if
drop get_ms
else
get_ms over minus 10 greater_than
if drop return endif
endif
repeat
# wait for the button to be pressed for at least 10 ms
sub wait_for_button_closed_10ms
get_ms
begin
# reset the time on the stack if it is pressed
button
if
get_ms over minus 10 greater_than
if drop return endif
else
drop get_ms
endif
repeat