27220 Parallax Inc, 27220 Datasheet - Page 224

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
I/O Pins are Variables Too
Remember that I/O pins are variables (INS and OUTS) and when doing simple
scanning there is no need to use an intermediary variable. Instead of:
… you can declare an input with the PIN type declaration and do it directly:
I don’t typically advocate putting multiple statements on a single line, but this is one
of those cases (an empty DO-LOOP) where it is the cleaner approach.
We can extend this with
count the number of times two discrete inputs are both high while running a loop.
Here’s the Power PBASIC style for doing that:
This works because we want to add one to the count variable when both buttons are
pressed.
parenthetical statement to zero or one, and the only time one will be returned is
when both buttons are pressed (assuming active-high inputs).
You Can do Fractions with the */ and ** Operators
The */ and ** operators allow the BASIC Stamp to multiply by fractional values.
The result will of course be an integer, but these operators will still simplify the
process, and oftentimes improve the accuracy of the result (over standard multiply
and divide techniques).
Main:
StartBtn
Main:
Count_Buttons:
DO
LOOP WHILE (startStatus = 1)
DO : LOOP WHILE (StartBtn = 1)
btnCount = 0
FOR idx = 1 TO 250
NEXT
By combining Btn1 and Btn2 with a logical AND we reduce the
startStatus = IN3
btnCount = btnCount + (Btn1 & Btn2)
PAUSE 40
combinatorial logic
PIN
3
. Let’s say, for example, that you want to

Related parts for 27220