Hello,
I'm playing around with a Sanwa digital arcade joystick that I scavenged up from a work project. I'm just barely an electrician by any real standard, and as far as I understand this is essentially just four buttons that you are pressing (completing a circuit) by moving the joystick in whichever direction. I confirmed this (and that the joystick works seemingly) by hooking it up to a multimeter and testing the connection between the "direction" cables and the "ground" cable while pressing a direction. As far as I can tell, it works fine.
I just barely understand digital inputs on the Arduino Uno (Have programmed some simple outputs to servos but that's pretty much it) but I wrote this simple program to spew out some info to let me know that I'm getting a reading from the joystick.
int inRight = 8;
int inLeft = 9;
int inDown = 10;
int inUp = 11;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(inRight, INPUT);
pinMode(inLeft, INPUT);
pinMode(inDown, INPUT);
pinMode(inUp, INPUT);
}
String p1 = "x";
void loop() {
// put your main code here, to run repeatedly:
int outOne = digitalRead(inRight);
int outTwo = digitalRead(inLeft);
int outThree = digitalRead(inDown);
int outFour = digitalRead(inUp);
Serial.println(outOne + p1 + outTwo + p1 + outThree + p1 + outFour);
delay(200);
}
Now when I directly connect the input to voltage, it seems to read just fine and I'll get my ugly stream of ones for that pin telling me something is happening. But when I plug the joystick in (and I've made sure I know which pin is the ground many many times) I get only ones from the digital reading, suddenly everything lights up. I've tried PULLUP i've tried PULLDOWN. I know there isn't a short in the joystick.
Could there really be that much noise coming from the joystick output? Or am I missing something more obvious? My understanding of circuitry is bad and my code it worse but this feels like it should be simple.
Thanks.