27220 Parallax Inc, 27220 Datasheet - Page 37

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-EX01-Flash_LED.BS2:
' {$STAMP BS2}
' {$PBASIC 2.5}
' -----[ Program Description ]---------------------------------------------
'
' Flashes an LED connected to P0.
' any BS2-family module.
' -----[ I/O Definitions ]-------------------------------------------------
AlarmLed
' -----[ Constants ]-------------------------------------------------------
FlashTm
' -----[ Program Code ]----------------------------------------------------
Main:
Behind the Scenes
Each of the BASIC Stamp’s I/O pins has three bits associated with its control. A bit in
the DIRS register determines whether the pin is an input (bit = 0) or an output (bit
= 1). If the pin is configured as an output, the current state of that pin is stored in
the associated bit in the OUTS register. If the pin is configured as an input, the
current pin value is taken from the associated bit in the INS register.
HIGH and LOW actually perform two functions with one command: the selected pin
is configured as an output (1 in the DIRS register) and the state bit is modified in
the OUTS register (1 for HIGH, 0 for LOW).
HIGH AlarmLed
PAUSE FlashTm
LOW AlarmLed
PAUSE FlashTm
GOTO Main
PIN
CON
0
500
This program will work, unmodified, on
' LED on P0
' delay 500 milliseconds
' turn the LED on
' turn the LED off

Related parts for 27220