Arduino Esplora

I have been tinkering with the Arduino Esplora.  The Esplora is quite a bit different, in terms of physical layout than your normal Arduino microcontroller.  It resembles a rather standard video game controller in it’s layout.  Also, there are a number of onboard sensors already onboard the circuit board and are multiplexed to an analog input pin on the Atmega processor.  Coding for the Esplora is also a bit different, though familiar to anyone who has programmed an Arduino before.  A specialized library made specifically for the Esplora makes accessing all the onboard sensors and serial communications a snap.

Over the course of a single evening I was able to put together a rudimentary game called “Cat And Mouse” using just the onboard hardware and two pieces of software.  One running on the Arduino, and the other a Processing sketch running on my Macbook.

The objective is quite straightforward.  One player, the “cat” uses the Esplora to move around a box on the screen.  Another player, the “mouse”, uses the computer mouse to move about the screen as well.  The cat tries to overlay his/her box on top of the mouse cursor and depress the joystick button.  If successful, the cat earns points.  If the cat presses the button but does not have the box over the mouse cursor, than the mouse accumulates points.  Also, to make use of the up, down, left and right buttons; I created the ability to change the cat box size with the up and down buttons.  To change the screen color, I wrote a function utilizing the left and right buttons.  Here is a quick video to make things a little more clear:

The point of this endeavor was not to create world-class gaming experience, but rather to determine how feasible the Esplora is at teaching fundamental hardware and software design concepts.  All in all, this a GREAT product in that that for approximately $60 you have a lot of sensors and solid microcontroller in one package.  You can get up and running with no additional hardware (aside from a  computer of course).  The software development environments are all free for download from Arduino and Processing‘s websites.

The Arduino is sending a packet of the sensor data (in ASCII) in the following format:

JoystickXposition, JoystickYposition, JoystickButton, UpButton,  DownButton, RightButton, LeftButtonn

The Processing sketch in turn listens for a complete packet and then breaks up ASCII string, converts the strings to integer values, and places them into an array for easy manipulation.

EDIT:  Since initial post, I have refined the code to:

  1. Debounce the up/down/left/right button inputs. (Arduino code)
  2. Display “MISS!” when the cat attempts a strike and fails. (Processing)
  3. Introduced a new game mechanic to make the number of points the cat earns be inversely proportional to the size of the box.  In other words, the smaller the box the more points the cat gets for a successful strike.  Vice versa, the the larger the box, the fewer points the strike is worth.  I think this will help offset the advantage the mouse has in the game.  (Processing)

I do need to go back and document the code better, which I will do shortly.  So check back here later if you need more insight to what the code is doing.

The code is below: