28123 Parallax Inc, 28123 Datasheet - Page 135

TEXT WHAT'S A MICROCONTROLLER

28123

Manufacturer Part Number
28123
Description
TEXT WHAT'S A MICROCONTROLLER
Manufacturer
Parallax Inc
Type
Programmingr
Datasheet

Specifications of 28123

Style
Book
Title
What's a Microcontroller?
Contents
Whats a Microcontroller? Text
Product
Microcontroller Accessories
Core Processor
PIC16C57c
Flash
128 Bytes
Operating Supply Voltage
9 V
Board Size
31 mm x 16 mm
Lead Free Status / RoHS Status
Not applicable / Not applicable
counter
this:
You can also make the servo turn the opposite direction by counting down instead of
counting up. In PBASIC,
argument is larger than the
FOR…NEXT
You can combine counting down with a
quickly in the clockwise direction like this:
The trick to getting the servo to turn at different rates is to use these
count up and down with different step sizes. The next example program uses these
techniques to make the servo’s horn rotate back and forth at different rates.
Example Program: ServoVelocities.bs2
' What's a Microcontroller - ServoVelocities.bs2
' Rotate the servo counterclockwise slowly, then clockwise rapidly.
' {$STAMP BS2}
' {$PBASIC 2.5}
counter
DO
DEBUG "Pulse width increment by 8", CR
FOR counter = 500 TO 1000 STEP 8
NEXT
PULSOUT 14, counter
PAUSE 7
DEBUG DEC5 counter, CR, CRSRUP
FOR counter = 500 TO 1000 STEP 8
FOR counter = 1000 TO 500
FOR counter = 1000 TO 500 STEP 20
each time through the loop (instead of 1) by modifying the
Enter and run the program.
As the program runs, watch how the value of
Terminal.
Also, watch how the servo behaves differently through the two different
FOR…NEXT
loop count from 1000 to 500:
VAR
loops. Both the servo’s direction and speed change.
Word
FOR…NEXT
EndValue
loops will also count backwards if the
argument. Here is an example of how to make a
STEP
argument to get the servo to rotate more
counter
changes in the Debug
FOR…NEXT
FOR
statement like
StartValue
loops to

Related parts for 28123