27297 Parallax Inc, 27297 Datasheet - Page 224

KIT STAMPWORKS WITH BS2-IC

27297

Manufacturer Part Number
27297
Description
KIT STAMPWORKS WITH BS2-IC
Manufacturer
Parallax Inc
Datasheet

Specifications of 27297

Lead Free Status
Contains lead
Product
Microcontroller Accessories
Lead Free Status / Rohs Status
Lead free / RoHS Compliant

Available stocks

Company
Part Number
Manufacturer
Quantity
Price
Part Number:
27297SQ
Manufacturer:
NS
Quantity:
4
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 27297