Need help mapping Esplora's accelerometer to joystick.

Hi all.
I figure this is fairly simple, I’m just not well versed in the code yet. I’m basically trying to get the accelerometer’s X,Y, and Z axis mapped to the joystick’s Left, Right, and Up so when the Esplora moves/tilts in a given direction, it will trigger the joystick to move in that direction.
Below is the start of the code, I’m assuming. This sketch originally just printed to the serial monitor but, I took out that portion since I don’t need it. It now awaits code to tell the joystick to trigger.
Any help will be appreciated!
Thanks in advance.

#include <Esplora.h>

void setup() {
  Serial.begin(9600); //start serial communication
  
}

void loop()

{
  
  int xAxis = Esplora.readAccelerometer(X_AXIS);    // read the X axis
  int yAxis = Esplora.readAccelerometer(Y_AXIS);    // read the Y axis
  int zAxis = Esplora.readAccelerometer(Z_AXIS); // read the Z axis

//to be continued...

Hi,
Welcome to the forum.
How do you get the joystick to move?
It is an input device, you move it with your hand.


Can you explain your project a bit more precisely?

Thanks .. Tom.. :slight_smile:

TomGeorge:
Hi,
Welcome to the forum.
How do you get the joystick to move?
It is an input device, you move it with your hand.
Can you explain your project a bit more precisely?

Thanks .. Tom.. :slight_smile:

Hi Tom,
Thanks for the reply. I made a 4K Pinball table using the Esplora as the control center. I want the accelerometer to act as the joystick. After thinking about this more, it's more or less having control of movement as you would on a tablet. (I.E. turn the tablet left, and the car on the screen goes left, etc.) But I just really need the sensors. The reason I need it mapped to the joystick is the control. A little to a lot, not just a button.
I made a video of work in progress if anyone cares to check it out. It's short.

Thanks again! I would love to get this implemented.

Hi,
I don't have an Esplora board, but from reading this;

The accelerometer is already on the board, looking at the arduino IDE in Examples there is under Esplora an example that puts the accelerometer output on the IDE monitor, you can start there to see the values you will need.

Tom.... :slight_smile:
PS I'm a bit puzzled, this is for a virtual pinball machine, why do you need joystick operation, I always thought the quickest way to get flipper operation would be the side buttons.

PS I'm a bit puzzled, this is for a virtual pinball machine, why do you need joystick operation, I always thought the quickest way to get flipper operation would be the side buttons

Please watch the video. I have the buttons. The joystick is mapped to "TILT" Nudge Left, Right, and UP. I would like the accelerometer to sense table movement and engage the TILT in the appropriate direction.