8 years, 7 months ago.

Joystick AnalogIn not working

Hello, i am using FRDM kl25z and joystick

Analog inputs PTB0 and PTB1 are not working

Code:

AnalogIn VRx(PTB0); AnalogIn VRy(PTB1); DigitalIn SW(PTE5);

if(VRy.read() < 0.3) Do something never happens, but

if(VRy.read() == 0) is true

/media/uploads/Muhamed/temp.png

Any help?

1 Answer

8 years, 7 months ago.

Hello,
You need to pay attention at the joystick connection. Maybe the one in image that you posted is made for arduino therefore the reference voltage supplied to the 2 potentiometers (the joystick is made from +mechanics to swing them) is printed on the board as 5V. The outputs will swing from 0 to 5V (or whatever you applied at that pin marked as 5V in silkscreen)
But, if you use with the Freescale's MKL25Z128VLK4 MCU (FRDM-KL25Z board) you must supply the reference 3,3V- same as the MCU supply (or lower if you supply the board with less )(maxx 3,6V!!!)

if you tried with 5V maybe you have the two pin gone...
done the correct wiring try again with an simple program (test it with another two pin...)to read the two pins PTB0 and PTB1

if you tried since the beginning with 3V3 as reference you may test the wiring using an DC voltmeter in Vrx and Vry. With joystick in the middle position you'll read about 1.65V in both. then check the code. step by step
good luck

Accepted Answer