27220 Parallax Inc, 27220 Datasheet - Page 58

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 Code ]----------------------------------------------------
Main:
Spin:
Clear_Game:
' -----[ Subroutines ]-----------------------------------------------------
Get_Random:
DO
LOOP
LEDs = %00111111
PAUSE 750
LEDs = %00000000
PAUSE 500
delay = 75
FOR spin1 = 1 TO 25
NEXT
IF (pattern = %00111111) THEN
ELSE
ENDIF
LEDs = %00000000
PAUSE 1000
GOTO Main
RANDOM rndVal
tone = rndVal & $7FF
pattern = rndVal & %00111111
LEDs = pattern
RETURN
GOSUB Get_Random
FREQOUT Speaker, 35 */ TAdj, tone */ FAdj
PAUSE 100
BUTTON PlayBtn, 0, 255, 10, swData, 1, Spin ' check for play
GOSUB Get_Random
FREQOUT Speaker, 25 */ TAdj, 425 */ FAdj
PAUSE delay
delay = delay */ $0119
FOR spin1 = 1 TO 5
NEXT
FREQOUT Speaker, 1000 */ TAdj, 330 */ FAdj
FOR spin2 = 0 TO 3
NEXT
LOOKUP spin2, [$00, $0C, $12, $21], LEDs
LOOKUP spin2, [665, 795, 995, 1320], tone
FREQOUT Speaker, 35 */ TAdj, tone */ FAdj
PAUSE 65
' get random number/tone
' sound the tone
' simulate machine reset
' initialize delay
' spin the wheel
' get random number
' wheel click
' pause between clicks
' multiply delay by 1.1
' if all lit, you win
' otherwise, groan...
' clear LEDs
' do it again
' get pseudo-random number
' keep in reasonable range
' mask out unused bits
' show the pattern

Related parts for 27220