Syntax Problem reading digital input on 40X

XLSERVICE

New Member
I have a 40x1 Picaxe and prototype board.

I am trying to check the status of pin 2 and 3 (Analogue 0 and 1 / input PortA 0 and 1) used as digital inputs. The High or Low status would then be pasted into variables
I have tried various versions of the code below but always get syntax errors.

If porta 8 = 1 then let b8=1 elseif pin porta 8 = 0 then let b8=0
endif
If porta 9 = 1 then let b9=1 elseif pin porta 9 = 0 then let b9=0
endif

or

If Pins porta 8 = 1 then let b8=1 elseif pin Pins porta 8 = 0 then let b8=0
endif
If Pins porta 9 = 1 then let b9=1 elseif pin Pins porta 9 = 0 then let b9=0
endif

Any help much appreciated
Cheers
Alan
 

lbenson

Senior Member
Would not encourage the use of "if ... then let ..."

This compiles; does it do what you want?

#picaxe 28X1
If porta pin0 = 1 then : b8=1 else b8=0 : endif
If porta pin1 = 1 then : b9=1 else b9=0 : endif
 

eclectic

Moderator
@Alan

First, please read manual 1 (v.6.7) pages 85 ...

Second, try something like this:

Code:
#picaxe 40X1

If porta pin1 = 1 then 
let b8=1
 elseif  porta pin1 = 0  then 
 let b8=0
endif
If porta pin2 = 1 then 
let b9=1 
elseif  porta pin2 = 0 then 
let b9=0
endif
Third. Make sure that PortA inputs 0 -1 (Legs 2 – 5)
have pulldown resistors. (10k)

e (AND OE)
 

XLSERVICE

New Member
Ah there is is, the answer to my question in black and white...

Thank you both. Sorry for wasting your time..

Cheers
Alan
 
Top