An analog joystick test

Here’s a little test program for the analog joystick. What it shows in my case is that the joystick does not (electrically) return to center when pressed to the right and then released slowly (in the other 3 directions it does return to center). It always mechanically returns to center. YMMV.

#include <MAKERphone.h>

MAKERphone mp;

void setup() {

void loop() {
  int x = mp.buttons.getJoystickX();
  int y = mp.buttons.getJoystickY();

  CRGB ledvalue[4];
  ledvalue[0].red = y*255/1100;
  ledvalue[0].green = (x+y)*255/2200;
  ledvalue[0].blue = abs(x-y)*255/1100;
  ledvalue[1].red = ledvalue[0].blue;
  ledvalue[1].green = ledvalue[0].red;
  ledvalue[1].blue = ledvalue[0].green;
  ledvalue[2].red = ledvalue[0].green;
  ledvalue[2].green = ledvalue[0].blue;
  ledvalue[2].blue = ledvalue[0].red;
  ledvalue[3].red = ledvalue[0].blue;
  ledvalue[3].green = ledvalue[0].green;
  ledvalue[3].blue = ledvalue[0].red;
  for(int i=0; i<8; i++) mp.leds[i] = ledvalue[i%4];

The rainbow LEDs effect is just for fun.

Wow, that’s really cool Frank!

I just tried it and got everything as it’s supposed to be. Could you try checking some joints on your Joystick?

The program is really simple and really cool, we’ll post it online if it’s cool with you so everyone can try it. :slight_smile:



There’s another mainboard on a slowboat from Croatia heading my way with a different joystick on it. I suspect the one I’m using for testing has some sort of mechanical play/hysteresis inside that prevents the resistive contact from sliding all the way back to center from the right. We’ll see what the other joystick does. For right now it’s fine as I don’t have a real analog joystick application in mind.

It’s already posted online if it’s here under the C++ apps topic, isn’t it; so anyone can try it right now (except for those poor souls that are having USB connectivity problems).


Okay, tell us if that one works.

Yes, it’s here now, but since we’ve now created some more programs and the users like you have done so too, we’re planning to put it on our website, just like we did with apps and games for MAKERbuino.

Of course, the creator of the app gets credited for it!

1 Like