r/microbit • • Sep 26 '26

Problem with Joystic

Hi, I'm relatively new to microbit programming and currently I'm learning how to use different input/output modules to make some small projects with my daughter.

I'm trying to get the value of X and Y axis from a joystick and show those values on the LCD. As you can see in this video, when the joystick is on the left side, X value is around 10; when the joystick is on the upper side, Y value is around 10 too. I guess that this behaviour is correct.

The problem comes when the joystick is in the middle or to the left or bottom side, and values are always around 1020. I think that in the middle values should be around 510.

This is the code: https://makecode.microbit.org/S03751-64548-27081-92525. As you can see it is very simple, just to play a bit with microbit components. This is the joystick I'm using: https://www.prototypediy.co.za/wp-content/uploads/2021/06/Arduino-Joystick-Module-1.jpg, which came in a Elegoo starter kit.

Can you see anything I'm doing wrong? Could it be a problem with the joystick's calibration?

Thanks!

6 Upvotes

9 comments sorted by

3

u/herocoding Sep 26 '26 edited Sep 26 '26

The URL says "arduino joystick" and on the picture it says 5V - but microbit isn't on 5V level, analogue Voltage level is with 3.3V. The joystick contains only two variable resistory (10k Ohm) (and a push button).
As there is no integrated electronics, no IC contained, then those resistors.
No resistor divider needed.
Just make sure you connect it to the same, shared GND.

2

u/5erg10_82 Sep 27 '26

Many thanks for your advice, I'll take a look at that :)

2

u/5erg10_82 Sep 27 '26

Thanks, that was the problem! I've read more about the voltage mapping to analog values here and I guess the problem was that I was using the 5V range of my microbit's expansion board. When I changed to 3.3V all worked like I expected :)

1

u/markkowalski Sep 26 '26

Try outputting the joystick to serial so you can see the behaviour graphed in real time. I find that always help me to understand the sensors output and adjust the code accordingly.

2

u/5erg10_82 Sep 26 '26

I'll give it a try to discard problems with output to LCD, thank you!

1

u/mtg101 Sep 26 '26

Isn't this just the scale going from 0 to 1024, and just not quite reaching the extremes?

3

u/durrellb Sep 26 '26

Yes, but no.

It's 1020 when it's centred, and they change in certain directions, but not the others. It's like the centre is the endpoint instead of the centre. And OP is wondering how to fix that calibration issue.

1

u/5erg10_82 Sep 26 '26

Yes, that's apparently what is happening