Shop OBEX P1 Docs P2 Docs Learn Events
Basic Stamp — Parallax Forums

Basic Stamp

eddie08eddie08 Posts: 3
edited 2008-06-05 03:23 in BASIC Stamp
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.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-06-03 03:37
    Have you tried your program? If not, try it and see what happens. Use some kind of feedback signal to let you know what the program is doing. You're probably using a piezo-speaker. You might use different tones to indicate where the program is at. Alternatively, you could add some LEDS to your setup and signal using those. You could also leave your BOE connected to your PC and use DEBUG statements to display messages.
  • eddie08eddie08 Posts: 3
    edited 2008-06-05 03:23
    I have tried and figured out what was going, thanks for the advice.
Sign In or Register to comment.