Pushbutton to Control Direction of Continous Rotation Servos
Modest Clown
Posts: 2
Hi Guys,
I'm new to stamps, and I was wondering if someone could help me figure out how to·create a ·simple Pushbutton sensor to help me control the direction of my servo motor.·Im pretty sure that I·have·the circuit connected properly I just need help with the coding aspect. I'm unfamilar with the commands for the stamps. I'm currently using the BS2. Would a TOGGLE·command be best or a IF ElSE··statement?
Thanks·
I'm new to stamps, and I was wondering if someone could help me figure out how to·create a ·simple Pushbutton sensor to help me control the direction of my servo motor.·Im pretty sure that I·have·the circuit connected properly I just need help with the coding aspect. I'm unfamilar with the commands for the stamps. I'm currently using the BS2. Would a TOGGLE·command be best or a IF ElSE··statement?
Thanks·
Comments
You need a program which will detect a pushbutton (using the BUTTON statement probably) that produces a value of 0 or 1. Simply compute a pulse width value based on that like buttonValue*500 + 500 will give a value of 500 if buttonValue is 0 and 1000 if buttonValue is 1.
The check for the state of the button could be in the same loop as the PULSOUT for the servo since both need to repeated periodically.