Last updated: 8th April 2011
Pololu Micro Maestro 6-channel servo controller used as a 10m turning target controller, driving a servo, with red and green LEDs, and Start, Face button and an optional Red LED Reset button.
Two versions of the script, Version A is 1 sequence of 7 seconds delay and 10 seconds Face, with one button Face and a second button to reset the Red LED.
Version B is 5 sequences of 7 second Edge and 3 seconds Face, combining the Face and Red LED reset functions (no video yet).
Short video is of Version A.
One point to consider is the make of servo used, Futaba servos rotate in the correct direction when using the code listed below.
Hitec servos rotate in the opposite direction.
Channel designations:-
0 is a Servo 1 is an Input 2 is an Input 3 is an Output 4 is an Output 5 is an InputInputs use a pull-up resistor (I used 1K resistors), connected to the board's 5V output.
Version A
# 10 second turning target control # Wait for start button or face button # After a 7 second delay move servo arm to face position # After a 10 second delay move servo arm to edge position # Return to the start of the sequence # Face button available # Reset Red LED to off button available # Servo Connected to Output 0 # Start button connected to Input 1 via pull up resistor # Face button connected to Input 2 via pull up resistor # Red LED connected to Output 3 # Green LED connected to Output 4 # Reset Red LED button connected to Input 5 via pull up resistor # Onboard Red LED signals Microswitch activation and delay timer # 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 button_c if reset_red_led endif repeat # These subroutines each return 1 if the corresponding # button is pressed, and return 0 otherwise. # button_a is assigned to channel 1 # button_b is assigned to channel 2 # button_c is assigned to channel 5 # These channels must be configured as Inputs in the # Channel Settings tab. sub button_a 1 get_position 500 less_than return sub button_b 2 get_position 500 less_than return sub button_c 5 get_position 500 less_than return sub turner led_on 8000 0 servo 6000 3 servo 7000 Delay 2000 3 servo 6000 4 servo 0 0 speed 4500 0 servo 10000 Delay 6000 3 servo 2000 4 servo 0 0 speed 8000 0 servo led_off return sub face 0 0 speed 4500 0 servo return sub reset_red_led 2000 3 servo return
Version B, this time with 5 sequences of 7 second Edge and 3 seconds Face, combining the Face and Red LED reset functions. One less button to wire up.
# 7 and 3 second turning target control # Wait for start button or face button # After a 7 second delay move servo arm to face position # After a 3 second delay move servo arm to edge position # 5 sequences # Face button available # Reset Red LED to off # Servo Connected to Output 0 # Start button connected to Input 1 via pull up resistor # Face button connected to Input 2 via pull up resistor # Red LED connected to Output 3 # Green LED connected to Output 4 # Onboard Red LED signals Microswitch activation and delay timer # 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 1 # button_b is assigned to channel 2 # These channels must be configured as Inputs in the # Channel Settings tab. sub button_a 1 get_position 500 less_than return sub button_b 2 get_position 500 less_than return sub turner led_on 8000 0 servo 6000 3 servo 7000 Delay 2000 3 servo 6000 4 servo 0 0 speed 4500 0 servo 3000 Delay 6000 3 servo 2000 4 servo 0 0 speed 8000 0 servo 6000 3 servo 7000 Delay 2000 3 servo 6000 4 servo 0 0 speed 4500 0 servo 3000 Delay 6000 3 servo 2000 4 servo 0 0 speed 8000 0 servo 6000 3 servo 7000 Delay 2000 3 servo 6000 4 servo 0 0 speed 4500 0 servo 3000 Delay 6000 3 servo 2000 4 servo 0 0 speed 8000 0 servo 6000 3 servo 7000 Delay 2000 3 servo 6000 4 servo 0 0 speed 4500 0 servo 3000 Delay 6000 3 servo 2000 4 servo 0 0 speed 8000 0 servo 6000 3 servo 7000 Delay 2000 3 servo 6000 4 servo 0 0 speed 4500 0 servo 3000 Delay 6000 3 servo 2000 4 servo 0 0 speed 8000 0 servo led_off return sub face 2000 3 servo 0 0 speed 4500 0 servo return
Updated: 8th April 2011
Site maintained by:-