28X1 input pins A3 and C3

LEH

Member
I have a picaxe 28X1. I have a keypad connected such that key 1 goes to pin A.3 and key 5 goes to pin C.3. The editor does not let me use pinA.3 only pin3, so I have in my code IF PIN3 = 1 THEN do this and another statement IF PINC.3 =1 THEN do this.
When I press 1 on the key pad nothing happens. When I press 5 on the key pad the picaxe does the code for pin3. Any idea how to get this to work? I have other keypad pins connected to A.0, A.1, and A.2, but the picaxe does not do anything when these keys are pressed.
 

inglewoodpete

Senior Member
I haven't programmed a 28x1 for about five years but I remember that addressing Port A was very restricted.

Looking at some old code of mine, I did the following to read a Port A pin:

Code:
If PortA pin3 = 1 Then
   <more of my code>
EndIf
 

Technical

Technical Support
Staff member
See the X1 appendix at the end of the PICAXE manual (part 1) about this portA notation on the older parts.
 

LEH

Member
Thanks for the tip. I am now able to read portA. For some reason I get a lot of false hits if I use If portA pin0 then code. This happened repeatedly after power up for about 30 seconds and then also sometimes thereafter. I jumpered portA pin3 to pinC.6 which was unused and changed the code to look for pinC.6 which solved that problem.
 

westaust55

Moderator
What are your inputs to the portA pins?
If switches, do you have pull up or pull down resistors so the inputs are not floating when the switch is open causing/allowing fluctuating states between low/0 and high/1.

I recall that there were reports that some folks had interference problems with portA pins for the 28X1 and 40X1 when used as analog inputs with a recommendation to pull unused portA pins low.
 

inglewoodpete

Senior Member
Thanks for the tip. I am now able to read portA. For some reason I get a lot of false hits if I use If portA pin0 then code. This happened repeatedly after power up for about 30 seconds and then also sometimes thereafter. I jumpered portA pin3 to pinC.6 which was unused and changed the code to look for pinC.6 which solved that problem.
False 'hits', as you call them, are most often caused by a floating input pin. Do you have a pull-up (alternatively pull-down) resistor connected to the Port A input pin?
 
Top