Tag Archives: JoystickShield

JoystickShield Library for Arduino

I recently bought the JoystickShield for Arduino from Sparkfun and after playing around with it for a while, I realized that we don’t have a good Arduino library to interface with the JoystickShield. As it always happens with me, I ended up creating one πŸ™‚

Features

The library supports the following events

  • All 8 directions of Joystick. (Up, RightUp, Right, RightDown, Down, LeftDown, Left and LeftUp)
  • Joystick button press
  • All 4 button press (Up, Right, Down, Left)

JavaScript influence

While designing the interface for the library, my JavaScript skills influenced me and I have added callback function support for all the events, in addition to the normal mode.

If you are wondering how I added support for callbacks in C/C++, then the answer is that I implemented them using function pointers. I would probably write an article explaining about it when I find some time. Meanwhile you can check the source code or check out the callback example sketch to find out how to use them.

More details and Download

You can find more details about the library at its homepage and can download it from github account. There are also examples in the /examples directory from which you can find out how to use the library in both the modes.

Try it out and let me know if you have any feedback/comments.

PS: BTW this is my first Arduino based library πŸ™‚

Posted in Arduino | Tagged , , , | Leave a comment