Simple alarm code - whats wrong?

radiogareth

Senior Member
This works fine......
init:
dirs=%00010111
symbol RED_LED=c.0
symbol GREEN_LED=c.1
symbol speaker=c.2
symbol Movement_Sensor=c.3

main:
if pinc.3=1 then goto alarm
high RED_LED
Pause 50
Low Red_LED
Pause 950
goto main

But if I replace the first line of main with:

"If Movement_Sensor=1 then goto alarm" the syntax checker chucks it out??? All the other symbols work as expected. It must be something obvious, but I'm missing it though a fog of passing lurgy ATM :-(

TIA
 

neiltechspec

Senior Member
I think you need to define your symbol as :-

symbol Movement_Sensor=pinc.3.

Just fell into that trap myself !.

Neil.
 

radiogareth

Senior Member
Try;

symbol Movement_Sensor=pinc.3
Thanks people, the above works. But ironically if you use pinc.2 for the output defines the syntax checker chucks THAT out!!. Must be something to do with input or output??

Whatever, I can now send my pupil home with a listing that makes sense and is loosely 'good practice'.
 

hippy

Ex-Staff (retired)
But ironically if you use pinc.2 for the output defines the syntax checker chucks THAT out!!. Must be something to do with input or output??
Almost. "C.2" is a pin number, which can be used for input or output, eg -

HIGH C.2
SERIN C.2, N2400, b0

The "pinC.2" is a variable, which contains the value read on C.2 input as 0 or 1, eg -

IF pinC.2 = 1 THEN MainLoop
LET b0 = pinC.2

If you try and mix the two -

HIGH pinC.2

That would take the input on C.2 ( 0 or 1 ) and then perform a "HIGH 0" or a "HIGH 1" not a "HIGH C.2".

The compiler rejects the use of pinX.Y variables when used as such because it is almost certainly not what was intended.
 
Top