122-28176 Parallax Inc, 122-28176 Datasheet - Page 32

GUIDE STUDENT PROCESS CONTROL

122-28176

Manufacturer Part Number
122-28176
Description
GUIDE STUDENT PROCESS CONTROL
Manufacturer
Parallax Inc
Datasheets

Specifications of 122-28176

Accessory Type
Manual
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Contains lead / RoHS non-compliant
For Use With/related Products
Propeller Education (PE) Kit
Lead Free Status / RoHS Status
Lead free / RoHS Compliant, Contains lead / RoHS non-compliant
Example Program: ConditionalLooping.bs2
' -----[ Title ]-----------------------------------------------------------
' Process Control - ConditionalLooping.bs2
' Sounds tone using conditional loops
' {$STAMP BS2}
' {$PBASIC 2.5}
' -----[ Declarations ]----------------------------------------------------
Photo
LED
Buzzer
PB
PBVal
PhotoVal
FreqVal
CountVal
X
' -----[ Main Routine ]----------------------------------------------------
DO
LOOP
' -----[ Subroutines ]-----------------------------------------------------
WaitForButton:
RETURN
GetFreq:
RETURN
GOSUB WaitForButton
GOSUB GetFreq
GOSUB GetCount
GOSUB SoundTone
PAUSE 1000
DEBUG CLS, "Press the pushbutton to begin",CR
DO
LOOP WHILE (PB=1)
DO
LOOP UNTIL (FreqVal <= 4000)
DEBUG CR,"Enter the frequency to play (1 to 4000)",CR
DEBUGIN DEC FreqVal
Enter, save and run ConditionalLooping.bs2.
To begin, press the pushbutton as directed by the Debug Terminal.
Enter a frequency to play and the number of times to play it by typing a value
into the white text box at the top of the Debug Terminal, and then pressing
Return or Enter.
Test using valid and invalid values.
PIN
PIN
PIN
PIN
VAR
VAR
VAR
VAR
VAR
0
5
10
13
Bit
Word
Word
Byte
Byte
' Alias for photo resistor circuit on P0
' Alias for LED on P5
' Alias for buzzer on P10
' Alias for pushbutton on P13
' Bit variable to hold pushbutton value
' Variable to hold RC Time value
' Frequency to sound
' Number of tones to sound
' General Counting variable
' loop until within range

Related parts for 122-28176