Old analog DB15 Joystick

I have a old Gravis Blackhawk joystick(pic and scheme below) that i figured the pinout of. i just opened up the back, and it doesn’t have any electronics, just a circuit board splitting out to all the buttons etc(no ICs etc, NOTHING)) it has 3 buttons on the stick, a slider and another button on the base , and of course the X + Y axis for the stick. All the buttons are wired to a pin of the DB15 connector and the other side goes to GND. The X + Y axis and the slider are connected to +5v and a individual pin for each on the DB15 also.
The X + Y axis go to a 95Kohm variable sliding resistor, and the slider goes to 180kohm variable pot. I can measure the varience by supplying 5v to the 5v pin and connecting the resistance volt meter to the 5V pin and the pin for the specific axis or slider.

how do i hook this up to arduino? i tried some of the tuts, but they dont work, i get 1023 as the constant out put. i had 5v to the joystick and each slider on a analog pin. also how would i connect the buttons as they go to GND when pressed.

thanks.

IIRC:

  • the switches can be connected to a digital pin. Be sure to use a pullup resistor on the arduino side (can be done in code)

in setup() ... pinMode(pin, INPUT); digitalwrite(pin, HIGH); // sets the pull up.

  • the middle of the potmeter/ slider can be connected directly to the analog pin.

Be sure to connect the GND to Arduino GND and optionally +5V to Arduino+5V (if the stick has no own powersupply)

-Yeah i already had buttons working, but thanks for the internal pull up info.(not sarcastic here :))

the problem is with the sliders…they dont work still, and how you said to hook them up, is how i had them hooked up. ill open the joy back up and get a pinout of the sliders…

Have you tried to confirm the working of the sliders with a DMM? (= Digital Multi Meter)

Can you post the code how you read the sliders?

in the slider jpeg attached; red is 5v, and the two greys both go to a pin on the DB15. the white box is unconnected.

yes, i did use a DMM. one probe on +5v and the other on the pin in the DB15 connector associated with the slider. both of the Grey pins on the slider must be connected together for a correct reading of resistance.

code im using:

int joyAxisX = 3;  //Joy X axis Analog pin 3
int joyAxisY = 4;  //Joy Y axis Analog pin 4
int XaS = 0;                  // variable to read the value from the analog pin 0
int YaS = 0;                  // variable to read the value from the analog pin 1


void setup() 
{
  Serial.begin(9600);
}

void loop()
{
  XaS = analogRead(joyAxisX);   
  YaS = analogRead(joyAxisY);  
  
  Serial.print('X');
  Serial.print(XaS);
  
  Serial.println();
  
  Serial.print('Y');
  Serial.print(YaS);
  
  Serial.println();
  delay(1000);
}

Slider.JPG

ok i works now :) none of the Pots in the joystick had GND connections, only +5v and the other pin goes to the DB15, none to GND. so soldered some wires to GND...

Ah! Well discovered!!!

The computer side of these old joysticks was capable of measuring a resistance.... The Arduino is, of course, "measuring the resistance", but as a reflection of the voltage coming out of a voltage divider. No ground connection to the bottom of the divider... as would work for the joysticks, in intended app... no division of voltage.

If you are trying to use one of these old joysticks, opening it, making the ground connection if necessary, is the best answer. (You can look for the connection with a multimeter beforehand... it may already be there.) If the joystick doesn't open nicely, you MAY be able to get away with a pull down resistor at the Arduino on the line from the joystick. Precision won't be as good, but it may be enough.

Some of those old joysticks had pretty dubious pots in them... use a meter to see how smooth the resistance change is on yours, today, before spending too much time on this!

I had this crazy idea of using the joystick to make a phoenix like game in the serial monitor. So, i would set the serial monitor windows size so that it only show a certain amount rows/columns then send enough lines of serial data at once to the computer to fill the size of the serial monitor. would this work?

i can get it to work as i Arduino cant send multiple lines of serial data at once. i would like to send something like this…
| |
| |
| |
| |
| |
| |—| |

then if i move the joystick left, send something like this…
| |
| |
| |
| |
| |
| |—| |

my issue right now is with the serial stuff, not the joystick(i got that working). how do i send multiple lines(displayed as multiple lines in serial monitor) at once using one Serial.print command? in the attached pic is what i want to do but with one serial.print command.

i guess i can write a C# app if what i seek isn’t possible…but if it is…Great!!

first create a var that represents the position cal it pos
you must split the println in multiple parts.

pseudocode

pos = pos - joystick.Left + joystick.Right;  // update position somehow..

Serial.print("|");
for (int i=0; i< pos; i++) Serial.print(" "); // can be done smarter I know
Serial.print("|--|");
for (int i=pos+4; i< max; i++) Serial.print(" "); // can be done smarter I know
Serial.println();

get the idea?

ahh but it still wont work no matter what because the serial monitor will always scroll as more input is received and you would see the "old" ship being scrolled up after another ship is made.