Compile Error

I get a compile error on lhe following line:
if alarmctrl2 = 1 then let statevar1 = statevar1 + 1
it is an empty box, and i can't spot anything wrong with the code.

Any ideas?

Code:
'Alarm UI Controller for PICAXE-28X 4MHz 16x gosub

symbol kpdctrl1 = pin0
symbol kpdctrl2 = pin1
symbol alarmctrl1 = pin2
symbol alarmctrl2 = pin3
symbol statevar1 = w0
symbol statevar2 = b3
symbol errloopvar = b4
symbol lcdbkltcount = b5

init:
	serout 7,T2400,(254,14)
	pause 30
	serout 7,T2400,(254,1)
	pause 30
	serout 7,T2400,(254,128,"Initializing...")
	pause 30
	serout 7,T2400,(254,192,"Don't Press Key!")
		wait 3
		if kpdctrl1 = 1 then errormsg
		if alarmctrl1 = 1 then errormsg
		if kpdctrl2 = 1 then errormsg
	serout 7,T2400,(254,128,"Alarm System")
	pause 30
	serout 7,T2400,(254,192,"Status: Normal")
goto setstate

setstate:
		if kpdctrl1 = 1 then let statevar1 = 1000
		if kpdctrl2 = 1 then let statevar1 = statevar1 + 100
		if alarmctrl1 = 1 then let statevar1 = statevar1 + 10
		if alarmctrl2 = 1 then let statevar1 = statevar1 + 1
goto readstate

readstate:
	if statevar1 = 0000 then stateA
	if statevar1 = 0100 then stateB
	if statevar1 = 1000 then stateC
	if statevar1 = 1100 then stateC
	if statevar1 = 0010 then stateD
	if statevar1 = 0011 then stateE
	if statevar1 = 1111 then stateF
	if statevar1 = 0000 then stateG

stateA: 'normal
	serout 7,T2400,(254,128,"Alarm System")
	pause 30
	serout 7,T2400,(254,192,"Status: Normal")
goto setstate

stateB: 'key pressed
	serout 7,T2400,(254,128,"Please Enter Code")
	pause 30
	serout 7,T2400,(254,192,"to Set Alarm")
goto setstate

stateC: 'correct code
	serout 7,T2400,(254,128,"Code Correct!")
	pause 30
	serout 7,T2400,(254,192,"Arming in 10s!")
goto setstate

stateD: 'armed
	serout 7,T2400,(254,128,"Alarm System")
	pause 30
	serout 7,T2400,(254,192,"Status: Armed")
	let lcdbkltcount = lcdbkltcount +1
	if lcdbkltcount = 30 then bkltoff
goto setstate

stateE: 'armed, triggered
	serout 7,T2400,(254,128,"Alarm!!  Enter")
	pause 30
	serout 7,T2400,(254,192,"Code to Reset!")
goto setstate

stateF: 'armed triggered, code correct
	serout 7,T2400,(254,128,"Correct Code:")
	pause 30
	serout 7,T2400,(254,192,"Resetting...")
goto setstate

stateG: 'normal
	serout 7,T2400,(254,128,"Alarm System")
	pause 30
	serout 7,T2400,(254,192,"Status: Normal")
goto setstate

bkltoff:
	'bkltpins must go low here.
goto setstate



sendback:
	'if then loops here.
goto errormsg


errormsg:
	serout 7,T2400,(254,128,"Fatal Error!")
	serout 7,T2400,(254,192,"Please Reset Sys")
		let errloopvar = errloopvar + 1
			if errloopvar = 30 then turnalloff
	wait 1
goto errormsg


turnalloff:
	serout 7,T2400,(254,10)
		let pins = %0000000 'perhaps a fault light here*
end
 

Technical

Technical Support
Staff member
Make sure you are using the latest version software. Correct syntax is separate lines, as let is a new command.

if alarmctrl2 = 1 then
let statevar1 = statevar1 + 1
end if
 
The program now works, although the chip now stops responding after a time; presumably because of the looping with the serial data.

how could I contnuously loop and check for state without having to constantly repeat the serial?

thanks
 
Top