• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Android Arcade Controller

I've been working on my latest software/hardware project and I've just posted a write-up on my blog. It's a bluetooth retro-arcade controller for Android devices.

I'm looking for some comments questions feedback as to what you think!



side-300x255.jpg


I vividly remember the days of putting my hard earned quarters into the latest video game at the the local arcade (Machine Shed). Disparately tying to get my initials on the high score board, hearing that familiar knock when someone got that extra game on the pinball machine…
Well it’s not the 1980′s anymore and those great games of the past have been replaced by XBox live and mobile handsets.
I’m not one to shy away from the latest in new technology, in fact, I welcome every new piece of techno-wizardry that comes my way. Although, I do miss the look of that retro-joystick and the familiar feel of the plastic button under my fingers. So out of my need to recapture some of my youth (maybe a bit of a stretch) and my love of new technology I set out to create a simple retro gaming controller for the Android platform.
Here’s a video preview of the final project:
Androcade Preview

Project Investigation
I wanted the project to meet a certain set of criteria:

  1. The controller had to work seamlessly with almost every Android device. This was the biggest hurdle as there is so many different devices to have to support…
  2. It had to be simple to use. Sometimes easier said than done.
  3. It had to support a joystick and at least 3 buttons.
Seems simple enough, right?
I started to investigate different ways to build my device. I began my journey down the path of using the Android ADK. This is a great development environment that allows you to use your Android device to interact with physical hardware. It is based on the Arduino which I was already familiar with! After further investigation I found that even though this platform was great it did not meet my needs, for a couple of reasons.

  1. It needs a physical connection with the device. I wanted to avoid having to plug in the Android device to my controller.
  2. It needs to be supported by whatever program is running on the Android device. In other words it was not a simple task to send commands to other Android programs using this platform.
So I scrapped the whole ADK idea, but, I did like the idea of using the Arduino for the input device. I already knew how to program it, it was simple to use and provided a great platform to prototype with. So I decided that this was the route to go for interacting with the controller.
My next task was to find a way for the Arduino to communicate with the Android device. After eliminating USB the next logical solution was Bluetooth.
I set out to find a inexpensive shield for the Arduino that would allow bluetooth communication to my Android device. Combing the internet I found several bluetooth shields for the Arduino but, they all cost around $40-$60 and being thrifty (OK – I’ll admit it… I’m cheap!) I wanted a less expensive solution.
After more searching I found what I think is the perfect solution! I found a $20 bluetooth shield that acts as a serial communication device. The product can be found here:
http://iteadstudio.com/store/index.php?main_page=product_info&cPath=18&products_id=307 
This device will work perfectly for my needs! I would simply send different characters over the serial port from the Arduino to the Android device and interrupt those commands on the Android to control games.
The next thing I had to figure out was how I was going to accept those commands from the bluetooth shield and send them to the games on the Android.
After a little searching and reading I settled upon writing a IME (Input Method Editor) for the Android that would take in the commands over bluetooth and send them out to the system as keyboard commands. This will work perfectly as a lot of the games that I wanted to play supported using the keyboard as an input device!


Everything is working great with with the software set up! It easily detects motion and takes pictures of the events. When we last posted about this I was in the process of adding notification to the software. I was able to add a couple of simple yet fun features to notify us when the software has detected motion.
I wanted a way to let us know when something was detected when we were at home so we could walk over to the computer and see what it caught. What better way to do that then to have the software send us a text message! Most carries have a way for you to send a text message by simply emailing your phone number using the carrier specific email address. After some brief searching I found that my carrier uses this format: yourphonenumber @ vtext.com sending an email to this address triggers their system to send a text message to your phone. NOTE: You will be charged for these if you don’t have an unlimited text plan be careful!

All I had to do now is add some code to send out the message after detection. Luckily .NET has some simple libraries to allow you to send out emails – so with just a few simple lines of code I was able to send an email that generates a text message whenever motion is detected. Here is the email code:
private void sendTextMsg()
{
MailMessage msg = new MailMessage();
msg.To.Add("send to email");
msg.To.Add("send to email #2");
msg.From = new MailAddress("yourfromaddress");
msg.Subject = "New Motion Detection.";
string mMailServer = "yourmailserver";
msg.Body = "New Image Taken!";

SmtpClient mySmtpClient = new SmtpClient(mMailServer);
System.Net.NetworkCredential cred = new System.Net.NetworkCredential("userName", "password");
mySmtpClient.Credentials = cred;

try
{
mySmtpClient.Send(msg);
}
catch (Exception e)
{

}
}

This works great I added a boolean to the code that is turned on and off by a menu choice allowing us to activate and de-activate the sending of messages when we want. It works great – my son gets really excited when he gets a text message that a new motion was detected!
That just wasn’t enough – there was something missing…
After my son and I discussed it we decided that we needed a way to see the images after they were captured but, without having to go to the computer to see them.
Since we already had the ability to send out email – we thought why not email the pictures to us so we can view them on our phones from anywhere!! Needless to say we changed the code once again and added the ability to send out an email with the images attached to it.
A couple of things to note are that attaching large amounts of photos to am email can make it very large depending on the size of the photos and some email providers won’t accept emails that large also, the processing time can be a hog and delay the rest of the program. To fix these we designed it to only attach the first five images that it collects and we also have it run on a separate thread so the program can go along it’s merry way as the email is processed and sent!
If your wondering about the attachments – it’s simple just add them to the
Message object like this
msg.Attachment.Add(path to file) .
As for the threading, once again, .NET makes it easy to create simple threading with the
BackgroundWorker object. I will leave this for another day as this post is already way too long.
One last thing… After all the fun we’ve had with the motion detection we have decided to change things up so we can do time-lapse! We think it would be really neat to see how things happen over time. So stay tuned for some fun with time-lapse coming in some later posts!
 
Very nice! And welcome to AF!

Would you like this moved to the Android games forum though? It seems like it pertains to those games more, and you will get more exposure there.

Edit: went ahead and moved it, I think you'll get even more feedback here:)

cheers
 
As fellow Android controller makers we salute you sir! We know it aint easy to get these things working but, once you finally do it is SO worth it! Awesome design by the way, maybe we can go tradesies when we launch the Easymote? :)
 
Looks fun, but how is the delay? You seem to be struggling a bit...

About using a cable to connect to the Android device: When you do that is it possible to get some power from that or do you still need a separate power source? From what I know about the USB spec you'd still need one, but I have no idea if mobile device makers have added some "enhancements" to the normal USB spec to let their devices act as pseudo-host devices.
 
Back
Top Bottom