28123 Parallax Inc, 28123 Datasheet - Page 109

TEXT WHAT'S A MICROCONTROLLER

28123

Manufacturer Part Number
28123
Description
TEXT WHAT'S A MICROCONTROLLER
Manufacturer
Parallax Inc
Type
Programmingr
Datasheet

Specifications of 28123

Style
Book
Title
What's a Microcontroller?
Contents
Whats a Microcontroller? Text
Product
Microcontroller Accessories
Core Processor
PIC16C57c
Flash
128 Bytes
Operating Supply Voltage
9 V
Board Size
31 mm x 16 mm
Lead Free Status / RoHS Status
Not applicable / Not applicable
DEBUG "Player A is the winner!", CR
ELSEIF (timeCounterB < timeCounterA) THEN
DEBUG "Player B is the winner!", CR
ELSE
DEBUG "It's a tie!", CR
ENDIF
The complete solution is shown below.
' What's a Microcontroller - Ch03Prj03_TwoPlayerReactionTimer.bs2
' Test reaction time with a pushbutton and a bi-color LED.
' Add a second player with a second pushbutton. Both players
' play at once using the same LED.
' Pin P3: Player A Pushbutton, Active High
' Pin P4: Player B Pushbutton, Active High
' {$STAMP BS2}
' {$PBASIC 2.5}
timeCounterA VAR
timeCounterB VAR
DEBUG "Press and hold pushbuttons", CR,
DO
DO
' Nothing
LOOP UNTIL (IN3 = 1) AND (IN4 = 1)
LOW 14
HIGH 15
PAUSE 1000
HIGH 14
LOW 15
timeCounterA = 0
timeCounterB = 0
DO
PAUSE 1
IF (IN3 = 1) THEN
"to make light turn red.", CR, CR,
"When light turns green, let", CR,
"go as fast as you can.", CR, CR
Word
Word
Quickest to release wins.
' Time score of player A
' Time score of player B
' Display reaction
' instructions.
' Begin main loop.
' Loop until both press
' Bi-color LED red.
' Delay 1 second.
' Bi-color LED green.
' Set timeCounters to zero
' If button is still down,

Related parts for 28123