My and function wont work

Grant666

Member
Hi

I'm trying to set up an and function on a picaxe 28x using portA pins 1 2 and 3

so I have tried

IF portA pin1 = 1 and portA pin2 = 1 then litelamp

the syntax check gets angry at the pin2 command point.

So can someone please enlighten me to my error

Thank you
The Grunta
 

Grant666

Member
Hi Neil

I tried that, no joy.

I have tried various variations plus the one you just suggested, none work....getting a bit perplexed

i actually want to sample pins A1, A2 and A3 to create a truth table reading in those inputs.

So eg. if pinA.1 = 1 and pinA.2 and pinA.3 = 1 then gosub litelamp but he syntax gets upset at pin 2 !!! I agree with you , it should work, but wont... Help !
 

techElder

Well-known member
When programming, one has to be very precise:

if pinA.1 = 1 and pinA.2 and pinA.3 = 1 then ...

is NOT the same as ...

if pinA.1 = 1 and pinA.2 = 1 then ...

the difference is you wrote pinA.2 with no comparison value.
 

Grant666

Member
When programming, one has to be very precise:

if pinA.1 = 1 and pinA.2 and pinA.3 = 1 then ...

is NOT the same as ...

if pinA.1 = 1 and pinA.2 = 1 then ...

the difference is you wrote pinA.2 with no comparison value.
Sorry that was 3 glasses of red wine and my poor typing skills where due to that ....I have tried it with correct syntax, still not happy...
 

inglewoodpete

Senior Member
It's a long time since I worked with a 28X.

I think once you choose a port then all following pins must be on the same port.

Try:
Code:
IF portA pin1 = 1 and pin2 = 1 then litelamp
Sorry, neiltechspec (edit: and Tex), I don't think that is correct for a the older chips.
 

eclectic

Moderator
Following the lead provided by IP in post#6..

#picaxe 28X
; See Manual 1, pages 97 - 98

main:
if portA pin0 = 1 AND pin1 = 1 AND pin2 = 1 AND pin3 = 1 then

gosub litelamp

endif
goto main

litelamp:
sertxd ("arrived")
return

e
 

Grant666

Member
Following the lead provided by IP in post#6..

#picaxe 28X
; See Manual 1, pages 97 - 98

main:
if portA pin0 = 1 AND pin1 = 1 AND pin2 = 1 AND pin3 = 1 then

gosub litelamp

endif
goto main

litelamp:
sertxd ("arrived")
return

e
Thanks for that, it works !!!!!!
 
Top