Sunday, April 17, 2016

Things to do with an old Android phone and an Arduino

A quick guide to the posts in this series (updated as the series is):

1. Arduino/Android Serial interface

A few years ago I participated in the "Color Run", a 5k race in which people throw colorful corn starch at each other. Apparently, it's something people consider to be "fun", something I am told I "don't have enough of", and that I should "get out of the house and meet more people, really, robots and cats aren't real socializing". Weirdos.

I didn't run, of course. I'm not exactly capable of running, but trudge along the path I did. On my person, in a bag, was my old trusty Galaxy SII. And somehow, when I returned from the "race", it emerged that the entire screen was cracked.

I was considering fixing it, but then realized I was incapable of staying sane for more than 3 hours without a phone, so I immediately bought a new Galaxy S4 and put the S2 in the drawer, soon to be forgotten.

Fast forward a few years, and I'm cleaning out my drawers. I find the S2. The screen is still broken, but no matter, a few eBay and Amazon clicks later I got myself a brand new screen digitizer assembly and fixed the phone.

Now I had a (almost - I didn't glue the new digitizer in properly) fully functional Android phone and nothing to do with it.

So now came the question: Can I use the USB OTG ("On-the-Go") features of the Galaxy S2 to control an Arduino driven robot (because, of course it's going to be a robot)? And what sensors and algorithms can I use on the S2 to make the robot do something awesome?

The answers are, in turn, "yes" and "a crapload".

The general idea is this:

1. Create Arduino driven robot using a kit, such as this (the exact kit I'm using was part of the Spark.io kickstarter kit, and the name of which is lost to the ravages of time; at least to me. If you know what it is, holler!) - you would of course need the motor shield, as well. My code depends on the L298P shield.

2. The Arduino code will accept commands (e.g. "f" for forward, "r" for right, etc. - protocol still a work in progress) over the serial link and activate the motors. Essentially, the Arduino will be a fairly dumb serial-to-motor bridge. I might throw in a couple of PIR sensors like these to activate the robot upon motion detection. We'll find out.

3. Have all the "smarts" of the robot run on the S2 - current thoughts include:

a. Use OpenCV and the camera for object detection, identification and collision avoidance (side note: I had a ping sensor connected to a previous version of the robot, and it drove the cat freaking wild; ultrasonic frequencies and pets do not mix. Don't try that at home, kids)
b. Some sort of gyroscope/vibration detection, maybe?
c. Use of the speaker to make noises that terrify the cat.
d. Have it receive commands via Bluetooth/Wifi/The web.

This is the sketch, in general terms. As the project progresses I will update the blog and whatever code ends up being created on Github.

Happy hacking!

No comments:

Post a Comment