[WIP] Joystick module via I2C pins

I decided, after finishing my MAKERbuino, that my first few projects would be physical alterations of the console and this is the result of my first attempt, a basic implementation of a joystick module I had laying around that can be utilised by any single-player game that already uses directional movement with slight modification to the game’s code.


I realised while deciding how to attach the joystick that I’ve soldered the audio jack on the wrong side of the board, whoops!

The joystick simply plugs onto the I2C pins at the top of the MAKERbuino using jumper cables and any game that isn’t already using the I2C pins can have its code slightly modified to use analog pins A4 and A5 as physical input instead of the directional buttons.

I used the ‘Pong’ example sketch from the Gamebuino library as the basis of my test code which I’ve uploaded to pastebin for reference and the wiring for the joystick to I2C pins is as following:

VCC/+5v to VCC/+5v
GND to GND
X axis to SDA
Y axis to SCL

My joystick comes with a button press feature but I have not worked out a simple way of wiring it to the MAKERbuino as of yet.

Links to the specific module I used and an alternative, any 2-axis analog joystick module should work however:
Jaycar module I used
Adafruit alternative

1 Like

Thanks for this experimentation. I’ll try too and will add the possibility to use this configuration of joystick in my game(s)
I hope you’ll post alot other experimentations :wink:
(I already know now that i can use A5 and A5 as analog entries)

1 Like

Looking forward to seeing what you come up with, I’m already keeping an eye on your parachute game which I imagine this can work well with :grinning:

As far as I can tell, both the I2C connectors are linked together on the board so both of them are identical and must use the I2C bus for multiple devices linked together, I’m not sure how to utilise the I2C bus yet so the analog pins can only be used directly for input with 1 module, I’m hoping @albertgajsak might be able to confirm this suspicion, I’ve got a lot to learn before I make some more advanced alterations.

Same to me but Albert have said they are working on the new tutorials for these parts now that the mane sending part is past but he have already to terminate the problem managment… Not easy to be patient … :slight_smile: but if all like you are sharing their experiment we will be able to advance with the experience of others.

@Jean-Charles_Lebeau, @Dalemaunder, this is a splendid project you have here.

Are you willing to write a short tutorial on how to use the Joystick and implement it in a game from the game library?
If yes, I’d love to post that on the official MAKERbuino tutorials page.

Btw. check out this old video where we’re connecting various modules to the MAKERbuino.

OK. I m on holidays atm but i’ll do after if not already done by Dalemaunder

The I2C is a bus for communication. Both sides require some sort of computing since it involves exchanging addresses, etc. Thus a simple joystick cannot work as an I2C device as is. It requires a dedicated microcontroller (like the Atmega 328P).
Nevertheless, a joystick can work on this port as the SDA and SCL pins can be used as regular I/O pins as well. In fact they have to use an ADC (analog to digital converter) pin to get an analog value. This is fortunately the case on these pins.

1 Like

Thank you for your mod.
I wrote a JoyStick Function to replaces calls of

gb.buttons.pressed(BTN_UP)
gb.buttons.pressed(BTN_DOWN)
gb.buttons.pressed(BTN_LEFT)
gb.buttons.pressed(BTN_RIGHT)

Here is the code :

boolean JoyStick(int BUTT) // Return true/false for the tested direction
{
	switch(BUTT)
	{
		case BTN_DOWN:
		{		
                   if (analogRead(JoyY_pin) >= 700)
				return true;
			else
				return false;
			break;
		}
			
		case BTN_UP:
		{
			if (analogRead(JoyY_pin) <=600)
				return true;
			else
				return false;
			break;
		}	
		case BTN_LEFT:
		{
			if (analogRead(JoyX_pin)<=600)
				return true;
			else
				return false;
			break;
		}
		case BTN_RIGHT:
		{
			if (analogRead(JoyX_pin)>=700)
				return true;
			else
				return false;
			break;
		}
	}
}
2 Likes