28122 Parallax Inc, 28122 Datasheet - Page 104

KIT WHAT'S A MICRO:PARTS ONLY

28122

Manufacturer Part Number
28122
Description
KIT WHAT'S A MICRO:PARTS ONLY
Manufacturer
Parallax Inc
Datasheet

Specifications of 28122

Accessory Type
Parts Kit
Product
Microcontroller Accessories
Core Processor
PIC16C57c
Flash
128 Bytes
Operating Supply Voltage
9 V
Board Size
31 mm x 16 mm
For Use With/related Products
Board of Education Full Kit
Lead Free Status / RoHS Status
Lead free / RoHS Compliant
Item-2
Players soon figure out that the delay from red to green is 1 second. After playing it
several times, they get better at predicting when to let go, and their score no longer
reflects their true reaction time.
The BASIC Stamp has a
random number:
For precision, you can use the */ operator to multiply by a value with a fraction to make
your answer more precise. The */ operator is not hard to use; here’s how:
1)
2)
3)
4)
Example: Let’s say you want to multiply the timeCounter variable by 3.69.
1)
2)
3)
4)
At the beginning of your code, add a declaration for a new variable called
value
pseudo random number sequence.
Just before the pause command, use the
new “random” value from the pseudo random sequence that started with 23.
RANDOM value
DEBUG "Delay time ", ? 1000 + value, CR
Place the value or variable you want to multiply by a fractional value before the */
operator.
Take the fractional value that you want to use and multiply it by 256.
Round off to get rid of anything to the right of the decimal point.
Place that value after the */ operator.
Start by placing timeCounter to the left of the */ operator:
Multiply your fractional value by 256: 3.69 X 256 = 944.64.
Round off: 944.64 ≈ 945.
Place that value to the right of the */ operator:
, and set it to 23. The value 23 is called the seed because it starts the
timeCounter VAR Word
value VAR Byte
value = 23
timeCounter = timeCounter */
timeCounter = timeCounter */ 945
RANDOM
command. Here is how to modify your code for a
RANDOM
command to give
' <- Add this
' <- Add this
' <- Add this.
' <- Add this.
value
a

Related parts for 28122