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

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: LightAlarmsWithSubroutines.bs2
' -----[ Title ]-----------------------------------------------------------
' Process Control - LightAlarmWithSubroutines.bs2
' Sounds alarm based on photoresistor readings
' {$STAMP BS2}
' {$PBASIC 2.5}
' -----[ Declarations ]----------------------------------------------------
Photo
LED
Buzzer
PhotoVal
PhotoMin
PhotoMax
' ---[ Initialization ] ------------------------------------------------------
PhotoMin
PhotoMax
PAUSE 1000
' -----[ Main Routine ]----------------------------------------------------
DO
LOOP
' -----[ Subroutines ]-----------------------------------------------------
ReadPhoto:
RETURN
CheckLightHigh:
RETURN
CheckLightLow:
GOSUB ReadPhoto
GOSUB CheckLightHigh
GOSUB CheckLightLow
PAUSE 500
HIGH Photo
PAUSE 10
RCTIME Photo,1,PhotoVal
DEBUG DEC PhotoVal, ",", DEC PhotoMin, "," ,DEC PhotoMax,CR
IF (PhotoVal < PhotoMin) THEN
ENDIF
IF (PhotoVal > PhotoMax) THEN
DEBUG "LIGHT LEVEL HIGH!",CR
FREQOUT Buzzer,100,3000
PAUSE 100
DEBUG "LIGHT LEVEL LOW!",CR
Enter and run LightAlarmWithSubroutines.bs2.
PIN
PIN
PIN
VAR
VAR
VAR
=
= 5000
500
0
5
10
Word
Word
Word
' Read light level and plot values
' Alias for photo resistor circuit on P0
' Alias for LED on P5
' Alias for buzzer on P10
' Variable to hold RC Time value
' Holds minimum light level value
' Hold maximum light level value
' Set minimum light value
' Set maximum light value
' Allow connection to stabilize -- for Chapter 2
' Test if high light level
' Test if low light level

Related parts for 122-28176