28123 Parallax Inc, 28123 Datasheet - Page 166

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
Likewise, if you have to recalibrate your scale factor or offset, you can also just change
the
Example Program: ControlServoWithPotUsingConstants.bs2
This program makes use of aliases in place of almost all numbers.
' What's a Microcontroller - ControlServoWithPotUsingConstants.bs2
' Read potentiometer in RC-time circuit using RCTIME command.
' Apply scale factor and offset, then send value to servo.
' {$STAMP BS2}
' {$PBASIC 2.5}
scaleFactor
offset
rcPin
delay
servoPin
time
DO
LOOP
Your Turn – Using Constants for Calibration and Easy Updating
As mentioned earlier, if you change the I/O pin used by the
you can simply change the value of the
HIGH rcPin
PAUSE delay
RCTIME rcPin, 1, time
time = time */ scaleFactor
time = time + offset
PULSOUT servoPin, time
DEBUG HOME, DEC5 time
CON
directives at the beginning of the program.
Enter and run ControlServoWithPotUsingConstants.bs2.
Observe how the servo responds to the potentiometer and verify that it’s the
same as the previous example program (ControlServoWithPot.bs2).
Assigning an alias is what you do when you give a variable, constant or I/O pin a name
using
VAR
CON
CON
CON
CON
CON
VAR
,
CON
, or
185
500
7
10
14
Word
PIN
.
rcPin
constant declaration.
' Scale scaleFactor.
' Offset by offset.
' Send pulse to servo.
' Display adjusted time value.
HIGH
and
RCTIME
command,

Related parts for 28123