Hi
I’m new to this and have spent some time on the forums and google looking for an answer to my problem with no luck though I am sure it should be easy to resolve.
My setup is a micro maestro with channel 0 and 1 set as switch inputs and channel 2 connected to the servo. The project is for an automated turning targets setup for pistol shooting. The button on channel 0 runs a servo sequence that waits 3500ms, turns 90 degrees, waits 4000ms then turns back 90 degrees. This part of the code works fine.
The button on channel 1 needs to turn the servo 90 degrees so the targets face the competitors, then when the button is pressed again, to turn the targets back 90 ready for the steward to press the other button starting the shooting sequence. I just can’t figure out how to do this bit. I tried adapting the code in the samples without success.
Thanks for any assistance
# 4 second turning target control
# Wait for start button or face button
# After a 3.5 second delay move servo arm to face position
# After a 4 second delay move servo arm to edge position
# Return to the start of the sequence
# Face button available
# Servo Connected to Output 2
# Start button connected to Input 1 via pull up resistor
# Face button connected to Input 2 via pull up resistor
# When the script is not doing anything else,
# this loop will listen for button presses. When a button
# is pressed it runs the corresponding sequence.
begin
button_a if turner endif
button_b if face endif
repeat
# These subroutines each return 1 if the corresponding
# button is pressed, and return 0 otherwise.
# button_a is assigned to channel 0
# button_b is assigned to channel 1
sub button_a
0 get_position 500 less_than
return
sub button_b
1 get_position 500 less_than
return
sub turner
4242 2 servo
3500 delay
7745 2 servo 4000 delay
4242 2 servo
return
sub face
# need help here!!
7745 2 servo
4242 2 servo
return