Shop OBEX P1 Docs P2 Docs Learn Events
TerminalOperatedSensorArrayYourTurn — Parallax Forums

TerminalOperatedSensorArrayYourTurn

I'm using the Student Guide "What's a Microcontroller?" text - version 2.2 on page 289. I'm adjusting the code for "Your Turn"

I keep getting a warning that the label is undefined - but I think we have already defined this. Here is a pic of the code that supposedly undefined...

Pushbutton_1.jpg


This is my code:

'What's a Microcontroller - TerminalOperatedSensorArray.bs2
'Use Debug Terminal to choose to read one of four sensors.


' {$STAMP BS2}
' {$PBASIC 2.5}


'
[ I/O Definitions ]


Pb1Pin PIN 3
Pb2Pin PIN 4
PotPin PIN 7
PhotoPin PIN 9


'
[ Constants ]


DelayRc CON 100
DelayReader CON 1500


'
[ Variables ]


request VAR Nib
time VAR Word


'
[ Main Routine ]


DO


' GOSUB Display_Menu
' GOSUB Get_Request
FOR request = 0 TO 3
ON request GOSUB Read_Pusbutton_1, Read_Pushbutton_2,
Read_Pot, Read_Photoresistor


NEXT


LOOP


'
[ Subroutine - Display_Menu ]


Display_Menu:


DEBUG CLS, "Menu: ", CR, CR,
"1) Pushbutton 1", CR,
"2) Pushbutton 2", CR,
"3) Potentiometer", CR,
"4) Photoresistor", CR, CR
RETURN


'
[ Subroutine - Get_Request ]


Get_Request:


DEBUGIN DEC1 request
request = request - 1


RETURN


'
[ Subroutine - Pushbutton_1 ]


Read_Pushbutton_1:


DEBUG CLS, ? Pb1Pin
PAUSE DelayReader


RETURN


'
[ Subroutine - Pushbutton_2 ]


Read_Pushbutton_2:


DEBUG CLS, ? Pb2Pin
PAUSE DelayReader


RETURN


'
[ Subroutine - Read_Pot ]


Read_Pot:


HIGH PotPin
PAUSE DelayRc
RCTIME PotPin, 1, time
DEBUG CLS, ? time, " "
PAUSE DelayReader


RETURN


'
[ Subroutine - Read_Photoresistor ]


Read_Photoresistor:


HIGH Photopin
PAUSE DelayRc
RCTIME Photopin, 1, time
DEBUG CLS, ? time, " "
PAUSE DelayReader


RETURN

Any suggestions as to what I've done wrong?

Thanks in advance,

EC
513 x 174 - 57K

Comments

Sign In or Register to comment.