27220 Parallax Inc, 27220 Datasheet - Page 64

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
ModeB:
ModeC:
ModeD:
ModeE:
Behind the Scenes
Overall, this program is simpler than it first appears. The main body of the program
is a loop. Timing through the main loop is controlled by the position of the
potentiometer. RCTIME is used to read the pot and during development the
maximum pot reading was found to be 695, and the minimum reading was 10. What
we’d like to do is convert the span 10 – 695 to 50 – 1000.
The process is actually quite simple: the desired output span (950) is divided by the
input span (685) to provide a scale factor of 1.3868. This factor is converted for use
with */ by multiplying by 256 (355 or $0163). In application the low end pot value
is subtracted from the raw input, the scale factor applied, and then the minimum
output value of 50 is added. Those with a flair for mathematics will recognize the
familiar
The code at Switch_Check looks to see if the button is pressed. If it is, the
variable, mode, is incremented (increased by 1). The modulus (//) operator is used
to keep mode in the range of zero to four. This works because the modulus operator
returns the remainder of an integer division. Since any number divided by itself will
READ (SeqA + offset), Lights
RETURN
offset = offset + 1 // BMax
READ (SeqB + offset), Lights
RETURN
offset = offset + 1 // CMax
READ (SeqC + offset), Lights
RETURN
offset = offset + 1 // DMax
READ (SeqD + offset), Lights
RETURN
RANDOM rndVal
Lights = rndVal & %00111111
RETURN
y = mx+b
equation.
' output new light pattern
' get random number
' light random channels

Related parts for 27220