Anything particular with B.0 on a 40X2 ?

pjrebordao

Senior Member
I'm trying to detect an on/off switch on pin B.0 using the following code:

init:
input B.0
main:
if pinB.0 = 0 then
sertxd("L",13,10)
else
sertxd("H",13,10)
endif
pause 300
goto main
end

I have B.0 grounded with a 1K resistor. The switch closes the circuit from B.0 to 5V, through a 1K resistor.
Running the code above, always shows the pin as being High, right from the start. However if I use another pin (say B.3), the code and circuit behave as expected.
Any clues ?
 

westaust55

Moderator
No immediate point springs to mind.
Can you post a schematic and photo showing exactly how the hardware is connected.
 

srnet

Senior Member
Some input pins do have slight different logic switching levels, though I have not checked if b.0 is one of these.

However if you want to be sure to have a pin to read logic high, pull it up to 5V, not 2.5V. Assuming of course that the PICAXE supply voltage is 5V.
 

hippy

Ex-Staff (retired)
As srnet suggests it's probably because you have a 1K pull-up and a 1K pull-down. Make the pull-down 10K and that should solve the issue.

Having a pull-up and pull-down is not common practice; see "PICAXE Manual 3 - Interface Circuits" for details of wiring a switch.
 

BeanieBots

Moderator
It's some other (probably wiring) fault.
If the input is always HIGH, then the potential divider action cannot be the cause because although it will be a problem, the result will be always LOW.
Suggest you post a picture of your setup
 

pjrebordao

Senior Member
Yes, being always HIGH, lead me to it.
It was a wiring fault, although not my own...
I'm using a Picaxe 28/40 protoboard and... pins B.0 and B.1 of the chip socket were left unconnected. Had to wire in 2 small jumpers.
 
Top