Hi, i am new to arduino but know a bit of C so the language wasn't hard to pick up. I was looking around for something to do with my new arduino and noticed my old sega genesis/megadrive controllers. i got a pinout from pinouts.ru and hooked it up to the arduino. I have genesis pins 7 and 8 connected to ground and pin 5 connected to 5v. pin 1-6(excluding 5) are connected to digital 1-5 respectively. I do not know much about how coontrollers work, my program is just supposed to display what if a button is being pressed after reading it, if it is not pressed the output is "none".
For some reason, it always senses left and start when they are read even if they are not pressed and it never senses right even when it is pressed. If anyone can help me understand more about the genesis controllers or can help me optimize my code that would be greatly appreciated. this is my code:
int up;
int down;
int left;
int right;
int a;
int start;
void setup()
{
Serial.begin(9600);
pinMode(0,INPUT);
pinMode(1,INPUT);
pinMode(2,INPUT);
pinMode(3,INPUT);
pinMode(4,INPUT);
pinMode(5,INPUT);
pinMode(6,INPUT);
}
void loop()
{
up = digitalRead(0);
if (up == LOW)
{
Serial.println("up");
delay(1000);
}
if (up == HIGH)
{
Serial.println("none");
}
down = digitalRead(1);
if (down == LOW)
{
Serial.println("down");
delay(1000);
}
if (down == HIGH)
{
Serial.println("none");
}
left = digitalRead(2);
if (left == LOW)
{
Serial.println("left");
delay(1000);
}
if (left == HIGH)
{
Serial.println("none");
}
right = digitalRead(3);
if (right == HIGH)
{
Serial.println("right");
delay(1000);
}
if (right == LOW)
{
Serial.println("none");
}
a = digitalRead(4);
if (a == LOW)
{
Serial.println("a");
delay(1000);
}
if (a == HIGH)
{
Serial.println("none");
}
start = digitalRead(5);
if (start == LOW)
{
Serial.println("start");
delay(1000);
}
if (start == HIGH)
{
Serial.println("none");
}
}