Basic Stamp
eddie08
Posts: 3
Hi,
I am new with pbasic can anyone help write pbasic code for a board of education, standard servo. I want the program to go a certain speed one way counter-clockwise (or clockwise) does not matter, and then decelerate in the same direction. Eventually I would like to integrate a flexi-force sensor with the servo. Here is my program so far.
' {$STAMP BS2}
' {$PBASIC 2.5}
'
Declarations
pulse_count VAR Word ' For...next loop counter.
finger_width VAR Word ' Variable stores finger pulse width.
'
Initialization
OUTPUT 2 ' Set P2 to output.
FREQOUT 2, 2000, 3000 ' Signal program is starting/restarting.
LOW 14 ' Set P14 to output-low.
'
Main Routine
main: ' Main routine.
forward: ' Forward routine.
FOR pulse_count = 1 TO 100 ' Loop that sends 100 forward pulses.
PULSOUT 14, 750
PAUSE 20 ' PAUSE for 20 ms.
NEXT
ramp_up_forward: ' Routine ramps into forward motion.
FOR pulse_count = 0 TO 250 STEP 2 ' For loop counts up in steps of 2.
PULSOUT 14, 1190 - pulse_count
PAUSE 20 ' Pause for 20 ms.
NEXT
STOP ' Stop until reset.
I am new with pbasic can anyone help write pbasic code for a board of education, standard servo. I want the program to go a certain speed one way counter-clockwise (or clockwise) does not matter, and then decelerate in the same direction. Eventually I would like to integrate a flexi-force sensor with the servo. Here is my program so far.
' {$STAMP BS2}
' {$PBASIC 2.5}
'
Declarations
pulse_count VAR Word ' For...next loop counter.
finger_width VAR Word ' Variable stores finger pulse width.
'
Initialization
OUTPUT 2 ' Set P2 to output.
FREQOUT 2, 2000, 3000 ' Signal program is starting/restarting.
LOW 14 ' Set P14 to output-low.
'
Main Routine
main: ' Main routine.
forward: ' Forward routine.
FOR pulse_count = 1 TO 100 ' Loop that sends 100 forward pulses.
PULSOUT 14, 750
PAUSE 20 ' PAUSE for 20 ms.
NEXT
ramp_up_forward: ' Routine ramps into forward motion.
FOR pulse_count = 0 TO 250 STEP 2 ' For loop counts up in steps of 2.
PULSOUT 14, 1190 - pulse_count
PAUSE 20 ' Pause for 20 ms.
NEXT
STOP ' Stop until reset.
Comments