Need help with an NES controller code

johnwasser:
So it looks like it reads from one controller connected to pins 2, 3, and 4. Do you have another controller connected to a different set of three pins? I don't see any code for reading a second controller.

No, I will simply expose a portion of the three wires (2,3,4) and wrap an striped wire around it so it can split off the connection. The reason I have to wire it like that is that If I try to add extra int pins like below:

latch = 2; // set the latch pin
int clock = 3; // set the clock pin
int data = 4; // set the data pin
latch = 5; // set the latch pin
int clock = 6; // set the clock pin
int data = 7; // set the data pin

The sketch would give me an error in the upload. I can't seem to get extra pin inputs to upload properly (although it would be ideal), so I will simply wire it as explained above. I had to do something similar to wire the controller 3.5v and the bluesmirf 3.5v together so I can get it to talk to my android (which is the ultimate goal).

johnwasser:
Did you mean that when you press Down (5) and Right (7) together you are getting only Down ("AS") and not Right ("SI") or Down-Right ("LQ")? That's because the big chain of IF-ELSE will only execute the first matching option it finds. Since Down will match
"if (controllerData[5] == 0)" it will not go on to check "if (controllerData[5] == 0 && controllerData[6] == 0)" or" if (controllerData[5] == 0 && controllerData[7] == 0)".

Hum, I think you might be onto something there. You picked out a bug with the d-pad that I have been experiencing but didn't mention in the post above. Its kind of hard for me to explain, but when I press Down (5) to Down+Right (57), when I press Right (7), it doesn't read it as being pressed. I have to lift my thumb and press it again for it to read. It basically doesn't let me roll the dpad at all. Does this symptom sound like the issue you addressed? If you think so, what would you suggest I change it to? This was something I was going to ask about later on, but it seems like you may have found the problem without me even mentioning it. Good job, and thanks!

No, where my problem lies is why I can't use every key on the keyboard. When I press Down, I get "AS" (but in actuality I really get "LS" the amarino program reads certain keys but types them as something else. Thats something else I would like to mention, but we can get back to that later). And when I press Down+Right I get "ASLQ" I can recieve all four letters because of changing that "length = length + 2;" line. But I can't, for example, change Down "AS" to Down "PS" It will only read the letter "S" and I have no idea why. Is there anything that I'm not explaining (considering I know little about this stuff)?