Hi, noob need help here please. :-[
I want to use all analog pins 0-5 as digital input pins. I know we can do this by assigning them as digital pins 14-19. So I connect all these pins with 6 pull up 10K resistors, and switches to ground to pull down and read LOW value. But strange things I can only digitalRead on pin 14 (analog 0) AND 19 (analog 5) only. When I test/print the value of all these pins with the switches open (meaning all the value should be HIGH, right?), I got only pin 14 AND 19 that is HIGH, while pin 15, 16, 17, and 18 are still LOW even though it is already pull up to VCC with the resistors. I tried the setup on the normal digital pins 8 to 13, and they works fine, so the component connection is fine, I am sure. Please help, I really need to use a lot of the pins as digital input. Tks a lot.
What type of arduino are you using?
Have you used the board for other stuff and maybe fried the other pins?
I am using Dorkboard with atmega328 with Lady Ada bootloader. I have tried to change the chip with another brand new 328, it still has same problem.
It kind of sounds like a hardware problem.. why not just use the internal pull-ups to take away from external components?
To enable them, first use pinMode to turn them into an input, then turn the pin high. Attach one side of the switch to ground, other to the input pin, and that's it, no resistors
Also, have you looked at using shift registers for your switches instead? You can read 8 buttons per chip, and you can use I believe 8 chips (probably more) with just 3 wires from the Arduino.
Here's an example:
Hi Captain.. tks for suggestion, actually before I put the resistor I have tries to use the internal pull-up, and I got same problem. So I thought the internal pull-up was fried, that is why I use the external resistors.
The ShiftIn register is great idea, but PCB (Protoboard actually ) and casing space is really a premium on my project, that is why I use dorkboard, there is already a Hope RFM12B wireless module, 3.3V step up module, mini joystick and mini BCD switch (not shown on the picture).
Big thanks for the suggestion, I might have to re-think this project. I will try to test these analog pins on the real Duemilanove/Diecimila and see whether I got same problem or not. Tks again.
It wouldn't hurt to post your code, just in case there is an issue there.
Solved..!!! lousy me.. bad solder joint only..!
measure all the voltage on the pull up resistors.. only two got HIGH 3.3V, the rest is way below 1V.. clean the connection and re-solder.. and Voila.. all HIGH 3.3V.. thanks for all your suggestion...
How do you reconcile your solution to the problem with this statement from your original post?
I tried the setup on the normal digital pins 8 to 13, and they works fine, so the component connection is fine, I am sure.
Don
Don
I mean "component connection" as following the electronic schematic... I use same schematic connection on pin 8-13 as using also pull up resistor, and they work fine. But on the pin 14-19, using same schematic with another pull up resistors, they dont works properly. If you see my photo, there are 6 resistors in the middle of the board (which I found 4 has bad connection latter) and there are several others on the top right corners which I use to connect to test pin 8-13. Sorry to give you confusion.