40X1 port A as digital IO
Womai may be right as I have not tried to do this.
But in reading the manual there is no reference to "
porta".
It
could be that you have to poke and peek the special fucntion registers to even set up a port A pin as a digital input. Something along these lines:
For each portA bit in question, Set the corresponding bit in the ANSEL register to a 0 to make the bit a digital IO (instead of Analogue)
Set the corresponding bit in the port A register TRISA) as a 1 to set the pin as an input.
then read the port A register with Peek 5, b0
So first, try what Womai has suggested . . .
EDIT:
In this thread, hippy has givien a clue:
http://www.picaxeforum.co.uk/showthread.php?t=10265&highlight=portA
I recall reading previously that portA pins (more than other inputs) need pull down reistors on unused inputs to ensure valid readings. I guess this also suggests portA can be read in BASIC.
Lets hope there is a way to do it thru BASIC as while the TRISA register (133) is accessible thru Poke and Peek commands, the ANSEL register (location 188) is outside the picaxe BASIC peek and poke range.
EDIT2:
tried hippys code from the above thread.
Syntax wise comes up okay but try to simulate or run and you get an error "unknown byte/bit variable"
The reason is that on portA bit/pin 4 (= physical pin 6) is used as the Serial Input line and not available under PICAXE BASIC for use as an input (analogue or digital). So skip the line I have highlighted in red.
Code:
b0 = 0
If PortA pin0 = 1 Then : bit0 = 1 : End If
If PortA pin1 = 1 Then : bit1 = 1 : End If
If PortA pin2 = 1 Then : bit2 = 1 : End If
If PortA pin3 = 1 Then : bit3 = 1 : End If
[COLOR="Red"]If PortA pin4 = 1 Then : bit4 = 1 : End If[/COLOR] ; do not use this line
[code]