Arduino Leonardo Analog Inputs as Digital

I am trying to make Intellivision controller adapters like these. The first one is based on the second one but updated a bit.

Intellivision Controller Adapter 1 And Intellivision Adapter 2

Everything works great if I use only digital pins. I wanted to put two controllers on one Arduino Micro. I need 16 inputs and ground. The Micro has 20 inputs (using analog). It should work. But if I use just 1 analog pin, this does not work. I am testing it with just one controller. If I use pins 2-9, it works fine. If I use 3-9 and A0 as pin 14, part of it doesn't work. It seems that if I use multiple analog pins, I get all kinds of ghost keys being pressed.

Could anyone tell me why it doesn't work when I use the analog inputs? Do you think the controllers can't pull the analog inputs to low maybe? Could I do it a different way with resistors or something? I know the first link has code for 2 controllers but he is using an MCP chip to make that happen (which I don't currently have). I would like to go without if possible. If not, I guess I will order one up.

I just figured I would try here first. Thanks for looking and for any help you can give.

J_K_M_A_N

I am not sure what causes the ghosting, but it is a big problem with keypads, which is essentially what an intellivision controller is. It would probably work a lot better if you add a diode to each input so that the current can't back-track and create false positives. If you use a set of diodes for both controllers, you could (probably) use the same pins for each intellivision controller and a couple of other pins as their grounds.
I also had a project that connected 2 C64 joysticks to the same set of pins, with diodes to each input, then just switching the ground pin between reads meant I could read each joystick independently without crossover.

I might try that. I just think it is strange that they should work like the digital pins but it gives problems. I was hoping I maybe did something wrong that was easily fixable. :frowning: Thanks for the idea.

J_K_M_A_N

J_K_M_A_N:
If I use 3-9 and A0 as pin 14, part of it doesn't work. It seems that if I use multiple analog pins, I get all kinds of ghost keys being pressed.

A0 is 18 on Leonardo.
Are you using 14 in your code? If so, change it to A0.