IF Problem

Im trying to flash a led when c.4 is high but this IF statement isn't working

Code:
if c.4 = 1 then goto flash
      ^

Error: Syntax error in this line!
What am i missing?

I have a 28x2 and the mode is set to 28x2/40x2
 

chipset

Senior Member
wheres the rest of the code? The if command requires more than what you wrote. The "if" requires a certain command set. If you just want it to goto flash when c.4=1 then write it like this.

Code:
c.4=1 goto flash
 
Last edited:
wheres the rest of the code? The if command requires more than what you wrote. The "if" requires a certain command set. If you just want it to goto flash when c.4=1 then write it like this.

Code:
c.4=1 goto flash
Even then, there still is a syntax error

i think my IF statement is correct because it follows:

IF var operator var/constant THEN GOTO label: (Does not need a ENDIF)
 
Last edited:
Even with a endif i still have a syntax error:
Code:
if c.4 = 1 then goto flash endif
      ^

Error: Syntax error in this line!
Code:
main:
if c.4 = 1 then goto flash endif
goto main:


flash:
high c.3
pause 500
low c.3
pause 500
goto main:
 

eclectic

Moderator
Try this please:

Code:
#picaxe 28x2

main:
if  pinc.4 = 1 then 

goto flash
endif
      
goto main

Flash:
;  .......
goto main
e
 

hippy

Ex-Staff (retired)
eclectic has identified the problem. "C.4" is a "pin number" in pre-X2 terminology, while "pinC.4" is a "pin variable", so the code for a pre-X2 would be ...

Main:
If pin4 = 1 Goto Flash
Goto Main

Flash:
High 3
Pause
Low 3
Goto Main

When translated for an X2 becomes something like ...

Main:
If pinC.4 = 1 Goto Flash
Goto Main

Flash:
High C.3
Pause
Low C.3
Goto Main
 
Top