Go Down

Topic: Calibration of an analog joystick (Read 3590 times) previous topic - next topic

skeeter_mcbee

I just got back from Radioshack with an analog joystick http://www.parallax.com/StoreSearchResults/tabid/768/txtSearch/joystick/List/0/SortField/4/ProductID/581/Default.aspx, and there seems to be a need for calibration. Whenever I track it's movements from the Serial Monitor, the minimum values I get for my y-axis is 75, and my x-axis is getting nothing less than 125. I've never used a joystick with my Arduino before and I have no idea what I'm doing.

retrolefty

#1
Aug 21, 2012, 05:22 am Last Edit: Aug 21, 2012, 05:24 am by retrolefty Reason: 1
Yea, those are not really precision devices and have no mechanical trim adjustments to play with. Your best bet is to just find out what the min and max counts are for each channel and use the arduino map command to convert the results to say 0-100 for each axis.

int axisX;
int axisY;
int xchannel = A0;  //analog input pin wired to X channel of joystick
int ychannel = A1;  //analog input pin wired to Y channel of joystick

axisX= analogRead(xchannel);
axisX = map(axisX,75,1023,0,100);

axisY= analogRead(ychannel);
axisY = map(axisY,125,1023,0,100);

The numbers in bold above would have to be found out from actual raw measurements of the min and max travel value in prior testing.

http://arduino.cc/en/Reference/Map

Good luck;

Lefty

skeeter_mcbee

Thanks, Lefty. I'm not much of a big Arduino user, so I never would have thought about that.

Go Up