27220 Parallax Inc, 27220 Datasheet - Page 75
27220
Manufacturer Part Number
27220
Description
BOOK STAMPWORKS
Manufacturer
Parallax Inc
Datasheet
1.27220.pdf
(230 pages)
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
- Current page: 75 of 230
- Download datasheet (3Mb)
Show_Die:
' -----[ Subroutines ]-----------------------------------------------------
Tumble_Die:
Behind the Scenes
This program borrows heavily from what we’ve already done and should be easy to
understand. What we’ve done here is added a bit of programming creativity to make
a very simple program visually interesting.
Of note is the Tumble_Die subroutine which actually does quite a lot of work. The
first thing this routine does is shake the random number generator. Since the main
loop will call this subroutine about every five milliseconds, it’s getting a lot of shaking
and should give us nice random results.
From the random number the die value is created. Remember what we learned
about the modulus operator: it will always return a value between zero and the
divisor. Since there are six faces on a die, we divide the random value by six and
take the modulus; this gives us zero to five. Adding one “fixes” the value so it’s
between one and six.
Finally, this same subroutine is responsible for updating the animated “bug” used to
indicate the die being shaken. If we updated the frame through every pass of the
subroutine the display would look more like a flickering zero than an animation – we
need to slow things down, perhaps updating the animation every tenth time through
(which would give us a bit more than 50 ms per frame). This is accomplished by
using doSpin as a timer. This value gets incremented then divided by 10 (with //)
on every pass; when the modulus result is zero it’s time to update the animation
READ (Digit0 + dieVal), Segs
PAUSE 3000
GOTO Main
RANDOM rndVal
dieVal = (rndVal // 6) + 1
doSpin = (doSpin + 1) // 10
IF (doSpin = 0) THEN
ENDIF
RETURN
spinPos = (spinPos + 1) // BugLen
READ (Bug0 + spinPos), Segs
' transfer die to segments
' hold for viewing
' start again
' stir random value
' get die val, 1 - 6
' update spin timer
' time for update
' yes, point to next pos
' output to segments
Related parts for 27220
Image
Part Number
Description
Manufacturer
Datasheet
Request
R
Part Number:
Description:
Microcontroller Modules & Accessories DISCONTINUED BY PARALLAX
Manufacturer:
Parallax Inc
Part Number:
Description:
BOOK UNDERSTANDING SIGNALS
Manufacturer:
Parallax Inc
Datasheet:
Part Number:
Description:
COMPETITION RING FOR SUMOBOT
Manufacturer:
Parallax Inc
Datasheet:
Part Number:
Description:
TEXT INFRARED REMOTE FOR BOE-BOT
Manufacturer:
Parallax Inc
Datasheet:
Part Number:
Description:
BOARD EXPERIMENT+LCD NX-1000
Manufacturer:
Parallax Inc
Datasheet:
Part Number:
Description:
CONTROLLER 16SERVO MOTOR CONTROL
Manufacturer:
Parallax Inc
Datasheet:
Part Number:
Description:
BASIC STAMP LOGIC ANALYZER
Manufacturer:
Parallax Inc
Datasheet:
Part Number:
Description:
IC MCU 2K FLASH 50MHZ SO-18
Manufacturer:
Parallax Inc
Datasheet: