Interfacing a Joystick with an ADC

Discussion in 'Embedded Systems and Microcontrollers' started by Header, Nov 15, 2009.

  1. Header

    Thread Starter New Member

    Nov 15, 2009
    5
    0
    Hi,

    I am attempting to interface a joystick that has two pins for each axis (like a normal resistor, except variable) to my μC's (ATmega32) ADC. My problem is that, I cannot figure out the proper way to connect it. I have tried connecting one pin to 5v and the other to my μC, but that yields no results.

    Any help would be appreciated!
     
  2. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    A simple way would be a voltage divider.
    Basically connect one of the 2 pins to ground and the other pin to the ADC channel and also to 5V through a fixed resistor. Pick a resistor that is maybe about half the maximum of the variable resistor and experiment from there.
     
  3. Header

    Thread Starter New Member

    Nov 15, 2009
    5
    0
    Okay, I have a voltage divider up and running, but the voltage on the ADC isn't changing enough(changes about one volt) to get a precise reading. Using the internal amp on the AVR results in a value of 255 no matter where I move the joystick.

    Thanks!
     
  4. beenthere

    Retired Moderator

    Apr 20, 2004
    15,815
    282
    Are you sure that joystick has an analog output? You should be able to feed it 5 volts and ground, and the outputs of both axes should be a voltage that varies from 5 volts and ground.

    With two pins, yours sounds like it might just have switches.
     
  5. Header

    Thread Starter New Member

    Nov 15, 2009
    5
    0
  6. beenthere

    Retired Moderator

    Apr 20, 2004
    15,815
    282
    According to the link, you put power to pins 2 and 4 (that would be ground and +5), and the other pins are the X and Y axis signals. You should be able to read the voltage outputs with a meter to see if it works properly - checking for resistance is not telling the whole story.
     
  7. Header

    Thread Starter New Member

    Nov 15, 2009
    5
    0
    Thanks - I did not understand what they meant by "supply power"; it is now working great!
     
Loading...