Unexplained Syntax Error

fierojo

New Member
I'm having what appears to be a simple problem but I don't understand how to fix it. The program should be simple and essentially has a PIR sensro turn on some LEDs.

The program is as follows:

#Picaxe 08M2
‘ ********************************************
‘ PICAXE-08M2 input/output pin definitions
symbol LED = C.4 ‘ Control line for all LEDs (output 4)
symbol PIR = C.3 ‘ PIR Input Signal (input 3)
‘ ********************************************
main: let LED = 0
If PIR = 1 then Flash
pause 1000
Goto main
Flash: Let LED = 1
Pause 5000
goto main

The syntax error is on the line starting with "main"

What am I doing wrong?

Thanks.

Fierojo
 

nick12ab

Senior Member
What am I doing wrong?
As well as not using [CODE][/CODE] tags (which isn't causing the problem but you should use them when posting code on the forum), you're trying to use pin constants as pin variables. When using the if or let commands, you have to use the pin variables. Use the pin constants with the high and low commands.

Example 1:
Code:
#Picaxe 08M2
' ********************************************
' PICAXE-08M2 input/output pin definitions
symbol LED = C.4 ' Control line for all LEDs (output 4)
symbol PIR = pinC.3 ' PIR Input Signal (input 3)
' ********************************************
main: low led
	If PIR = 1 then Flash
	pause 1000
	Goto main
Flash:high LED
	Pause 5000
	goto main
Example 2:
Code:
#Picaxe 08M2
' ********************************************
' PICAXE-08M2 input/output pin definitions
symbol LED = pinC.4 ' Control line for all LEDs (output 4)
symbol PIR = pinC.3 ' PIR Input Signal (input 3)
' ********************************************
	output C.4
main: led = 0
	If PIR = 1 then Flash
	pause 1000
	Goto main
Flash:led = 1
	Pause 5000
	goto main
 
Top