Error:148 - help with program to drive motors based on color sensed by camera
spathrw
Posts: 6
The students are using a camera that senses colors.· They
have this working properly.· They also have the program
driving a motor.
The problem:· They can not get the motors to drive based on
the color sensed.
This is the error:· Error:148:Expected a Label
Program line is:·
Line IF (pRed<85) AND (pGREEN<42) AND· (bBLUE<26) THEN...
have this working properly.· They also have the program
driving a motor.
The problem:· They can not get the motors to drive based on
the color sensed.
This is the error:· Error:148:Expected a Label
Program line is:·
Line IF (pRed<85) AND (pGREEN<42) AND· (bBLUE<26) THEN...
Comments
If you post the program we can offer some suggestions, but the label missing is a subroutine, variable, or something similar that is used in the program that is not being declared somewhere. Can you post the entire program using the Attachment Manager?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Respectfully,
Joshua Donelson
www.parallax.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
' {$PBASIC 2.0}
Out CON 7
S3 CON 0
S2 CON 1
LED CON 5
pRED CON 15
pGREEN CON 12
pBLUE CON 9
RED VAR Word
GREEN VAR Word
BLUE VAR Word
Counter VAR Word
START:
HIGH LED
DO
GOSUB Register
GOSUB Seperator_move
LOOP
Register:
GOSUB Color
DEBUG "R", DEC3 RED
DEBUG " G", DEC3 GREEN
DEBUG " B", DEC3 BLUE
DEBUG CR
RETURN
Color:
LOW S2
LOW S3
COUNT Out, pRED, RED
HIGH S3
COUNT Out, pBLUE, BLUE
HIGH S2
COUNT Out, pGreen, GREEN
RETURN
Seperator_move:
IF (pRed < 85) AND (pGREEN < 42) AND (pBLUE < 26) THEN SHIFT:
FOR Counter = 1 TO 24
PULSOUT 13, 750
GOSUB Semi_seperator
PAUSE 20
NEXT
FOR Counter = 1 TO 24
PULSOUT 13, 850
PAUSE 20
NEXT
ELSEIF (pRED < 55) AND (pGREEN < 76) AND (pBLUE < 43) THEN SHIFT:
FOR Counter = 1 TO 64
PULSOUT 13, 750
GOSUB Semi_seperator
PAUSE 20
NEXT
FOR Counter = 1 TO 64
PULSOUT 13, 850
GOSUB Semi_seperator
PAUSE 20
NEXT
ELSEIF (pRED < 31) AND (pGreen < 37) AND (pBLUE < 43)THEN SHIFT:
FOR Counter = 1 TO 104
PULSOUT 13, 750
GOSUB Semi_seperator
PAUSE 20
NEXT
FOR counter = 1 TO 104
PULSOUT 13, 850
PAUSE 20
NEXT
ELSE SHIFT:
FOR Counter = 1 TO 144
PULSOUT 13, 750
GOSUB Semi_seperator
NEXT
FOR counter = 1 TO 144
PULSOUT 13, 850
PAUSE 20
NEXT
ENDIF
PAUSE 20
RETURN
Semi_seperator:
FOR Counter = 1 TO 24
PULSOUT 12, 750
PAUSE 20
NEXT
RETURN
Program attached.
Thanks for helping.
Are you using the TAOS (TCS3200-DB Color Sensor) color sensor module? Or what camera are you using?
I see the program is using ELSEIF, and that is a PBASIC 2.5 command. What you would want to do is use the 2.5 PBASIC directive to select the latest command set in PBASIC and try the run the program again.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Respectfully,
Joshua Donelson
www.parallax.com
·I dont think you are running into a barrier but a formatting related issue. I see that you are using a SHIFT routine a number of times. Since each one is doing something different you would want to give unique names like you are using the Simi_seperator routine, so something like SHIFT_1, SHIFT_2, and so on.
·You can try something like the following; breaking the program up into easier to manage parts. Each IF...THEN statement has a specific place to jump to if the statement is true.
Seperator_move:
·· IF (pRed < 85) AND (pGREEN < 42) AND (pBLUE < 26) THEN SHIFT_1
·· ELSEIF (pRED < 55) AND (pGREEN < 76) AND (pBLUE < 43) THEN SHIFT_2
·· *other IF...THEN statements continued here...
'· Sub Routines Names
SHIFT_1:
··· FOR Counter = 1 TO 24
······ PULSOUT 13, 750
······ GOSUB Semi_seperator
······ PAUSE 20
······ NEXT
··· FOR Counter = 1 TO 24
····· PULSOUT 13, 850
····· PAUSE 20
····· NEXT
RETURN
SHIFT_2:
···· FOR Counter = 1 TO 64
······· PULSOUT 13, 750
······· GOSUB Semi_seperator
······· PAUSE 20
······· NEXT
····· FOR Counter = 1 TO 64
······· PULSOUT 13, 850
······· GOSUB Semi_seperator
······· PAUSE 20
······· NEXT
RETURN
** other Sub routines continued here
Hope this helps,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Respectfully,
Joshua Donelson
www.parallax.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Respectfully,
Joshua Donelson
www.parallax.com
·There is a specific format that a IF...THEN statement must follow to properly compile. An IF...THEN statement can be completed on one line, which does not need an ENDIF, or multiple lines; the common practice when using ELSE and ELSEIF, followed by an ENDIF.
·I would suggest reviewing the IF...THEN statement in the BASIC Stamp Syntax & Reference Manual as there are some nice examples of using a ELSEIF with an IF...THEN command with some code snippets. Here is a link for your convenience.
BASIC Stamp Syntax & Reference Manual:
http://www.parallax.com/Portals/0/Downloads/docs/prod/stamps/web-BSM-v2.2.pdf
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Respectfully,
Joshua Donelson
www.parallax.com