27220 Parallax Inc, 27220 Datasheet - Page 137

BOOK STAMPWORKS

27220

Manufacturer Part Number
27220
Description
BOOK STAMPWORKS
Manufacturer
Parallax Inc
Datasheet

Specifications of 27220

Accessory Type
Booklet
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
StampWorks
Lead Free Status / RoHS Status
Lead free / RoHS Compliant, Not applicable / Not applicable
Program: SW21-EX22-Analog_Out.BS2
' {$STAMP BS2}
' {$PBASIC 2.5}
' -----[ Program Description ]---------------------------------------------
'
' This program demonstrates how the PWM command can be used with an opamp
' buffer to create a variable voltage output.
' -----[ I/O Definitions ]-------------------------------------------------
D2Aout
' -----[ Constants ]-------------------------------------------------------
CycAdj
OnTime
' -----[ Variables ]-------------------------------------------------------
level
mVolts
' -----[ Initialization ]--------------------------------------------------
Reset:
' -----[ Program Code ]----------------------------------------------------
Main:
DEBUG CLS,
DO
LOOP
FOR level = 0 TO 255
NEXT
FOR level = 255 TO 0
NEXT
PWM D2Aout, level, (OnTime */ CycAdj)
GOSUB Show_Level
PWM D2Aout, level, (OnTime */ CycAdj)
GOSUB Show_Level
"Analog Output
"--------------- ", CR,
"level....
"mVolts...
PIN
CON
CON
VAR
VAR
0
$100
5
Byte
Word
", CR,
", CR,
"
' analog out pin
' x 1.0, cycle adjust
' 5 ms
' analog level
' output in millivolts
' increase voltage to LED
' decrease voltage to LED
' do it again

Related parts for 27220