I know it seems like I ask a new dumb question everyday, but here goes:
Trying to (without the use of the library available to me, for practice purposes) read data from my SNES controller to arduino. I've read through the serial protocol that it uses, and have checked the wires I have attached to my board with the set up used by SNES: Latch into digital 2, Clock into digital 3, Serial data into digital 4. GND and 5v to ..GND and 5v.
const int dataLatchPin = 2;
const int dataClockPin = 3;
const int dataSerialPin = 4;
However, with the above code, I am reading '1' without any buttons pressed, but '0' when I press up on the d-pad.
That code will only ever read back a zero or a 1. You are doing nothing with the clock or latch pin. I am not familiar with the SNES but it looks like there is some sort of serial protocol involved. What ever it is you are not driving it.
Hey grumpy_mike. I appreciate that it's serially controlled - and I had code to send out the latch signal and clock signal, and to read the incoming serial data (although that was probably flawed). When I got this one result that didn't match with what I was expecting from the serial data, I progressively commented away all of my code to try to identify the problem, until I was left with the code you see quoted and the problem still intact.
I just didn't want to inundate anyone looking at the problem with code that obviously had no bearing on it.
EDIT: The problem was that I was receiving a 0 even when I was only expecting to see 1s, or at the very most a 'blip' at zero when the clock signal went into the right cycle number. But I was just reading 0 for as long as my controller was down. Hope that makes it clear.
Thanks for the replies though, you've been really useful in my learning process.