Sei sulla pagina 1di 1

<!-- saved from url=(0111)http://www.teachengineering.

org/collection/nyu_/activi
ties/nyu_gatorade/nyu_gatorade_activity1_meterprogram.bs2 -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=GBK"></h
ead><body><pre style="word-wrap: break-word; white-space: pre-wrap;">' {$STAMP B
S2}
' {$PBASIC 2.5}
Light VAR OUTL ' Light is a variable that drives th
e low byte high (1) or Low (0)
cnt VAR Word ' cnt is a word sized variable that
records the output signal form the 555 timer.
' This value will change during the
measurement condcutivity
DO
HIGH 9 ' Turn on the 555 oscillation.
COUNT 10, 1000, cnt ' Count for one second.
DEBUG HOME, "cnt = ", DEC5 cnt ' Show values in the debug terminal.
DIRL=%11111111 ' Configure all pins (0-7) in the Lo
w Byte as outputs
IF (cnt =0) THEN ' If the value of Cnt is 0,
Light=%00011111 ' Then drive pins 0 - 5 High
PAUSE 100 ' Hold for 100 millseconds (0.1 s)
Light=%00000000 ' Then drive pins 0 - 5 Low
PAUSE 100 ' Hold for 100 millseconds (0.1 s)
ELSEIF (cnt &lt;=900 ) THEN ' Otherwise, if the value of Cnt
is less than or equal to 900,
Light=%00000000 ' Then drive pins 0 - 5 Low (Turn of
f all LEDs). This should correspond to the meter being placed in water.
ELSEIF (cnt&gt;901 AND cnt&lt;= 1200) THEN ' Otherwise, if the value of
Cnt is between 901 and 1200,
Light = %00000001 ' Then drive pin 0 High (Turn on the
1 LED). This should correspond to the meter being placed in 0.01 M NaCl.
ELSEIF (cnt&gt;1201 AND cnt&lt;= 1700) THEN ' Otherwise, if the value of
Cnt is between 1201 and 1700,
Light= %00000011 ' Then drive pins 0 - 1 High (Turn o
n the 2 LEDs). This should correspond to the meter being placed in 0.02 M NaCl.
ELSEIF (cnt&gt;1701 AND cnt&lt;= 2200) THEN ' Otherwise, if the value of C
nt is between 1701 and 2200,
Light=%00000111 ' Then drive pins 0 - 2 High (Turn o
n the 3 LEDs). This should correspond to the meter being placed in 0.03 M NaCl.
ELSEIF (cnt&gt;2201 AND cnt&lt;= 3000) THEN ' Otherwise, if the value of C
nt is between 2201 and 3000,
Light=%00001111 ' Then drive pins 0 - 3 High (Turn o
n the 4 LEDs). This should correspond to the meter being placed in 0.04 M NaCl.
ELSEIF (cnt&gt;3001) THEN ' Otherwise, if the value of Cnt
greater than 3001,
Light=%00011111 ' Then drive pins 0 - 4 High (Turn o
n all 5 LEDs). This should correspond to the meter being placed in 0.05 M NaCl.
ENDIF ' End if
LOOP ' Back to begining of program. Loop
ifinitely.</pre></body></html>

Potrebbero piacerti anche