Oh, cloud. What can’t you do?

A week or so ago, I was at my friend’s place and was playing with his IPad. I don’t have any type of tablet myself, but once I win the lottery, watch out. I am intrigued by the functional ability of such small form-factor devices (IPads, IPhones, IPod Touches, Android tablets, etc). I guess I’im looking at these things through the eyes of someone who once had a 286 with dual floppy drives. I don’t mean the nifty 3.5″ either. I’m talking the 5.25 drives.  Remember using a paper punch to make your single-sided disk double sided?  Yeah, those disks.  That thing took up my entire desk.

I realize that I need to change my approach on functionality of mobile computing.  Yes, the processor in my iphone is a monster compared to even desktops that are a few years old, but how it is used is different.  Can it do image manipulation such as photoshop?  Sure, but that would put strain on everything else such as memory and data storage.  How do we unload such bulk from computing while keeping functionality?  Instead of hording the latest and greatest technological architectures, let’s steal from the best technology of the 1960s: thin client.

Going back to my childhood, I remember being amazed that every checkout lane in the grocery store was able to know the price of a loaf of bread.  I was amazed that whenever the price of that loaf of bread changed, someone would have to go around to each register and update the price in each individual register.  Obviously, it doesn’t work that way.  None of the registers have the ability to store the price of any given product.  Instead, they are all connected to a centralized computer that does all of the pricing.  Fast forward to present day: pixlr.com is a website that allows web-enabled devices to execute the functions of photoshop.  Now any system with a web browser can edit photos without having photoshop A) installed and B) using system resources.  The processing and storage exists on some server “out there” somewhere.  The final result is sent back to the user and the device at hand (most literally) doesn’t even know what is happening.

Call it cloud computing, thin client computing, or voodoo for that matter, this gives us immense flexibility.  All a device needs to be able to do at this point is connect to a resource that is designed to accomplish a task and then send the result back.  Any new task that is designed can get its own existance out in the cloud.  Once the user knows where to look for it, the mobile device has everything it needs to add the given functionality to its Batman-style utility belt.

So I got to thinking the other day; can I program my Arduino through the cloud?  If I can use photoshop on my IPhone using a cloud app, why couldn’t I do a little bit of programming?  After doing a little research, I found that there are apps out there that allow users to develop applications through web-enabled devices.  The one I have been playing with for the past day is Compilr.  This web site allows user to develop applications in C#, VB.Net, Java, PHP, Ruby, C++ JavaScript, and Python.  Not a bad list!  The web application contains an IDE (programming environment) that looks a whole lot like the professional ones.  It allows you to write code, build and compile, and download the application once complete.  The cool thing about a site like this is that it could be used via an IPad or Android tablet if the developer wants to bring his or her mobile device to the beach, etc.  Yeah, laptops used to be the tool of choice for this, but at some point, nobody wanted to carry one of those along with them anymore.  Apparently, laptops are too bulky.  Go figure.

Conceptually, this is exactly what I’m looking for.  I could write code, store it on the cloud, and then pull it down when I’m ready to deploy it to the Arduino.  The problem with Compilr, however, is that it doesn’t have an environment for Wiring, which is the language used by Arduinos.  I could use the C++ environment, which would be close enough for my purposes, but I want something that is native.  Furthermore, since there is no native support for Wiring, the application can’t be built on the cloud like it can with the supported languages.  Ideally, a user should be able to plug an Arduino into the tablet in some way or another and then click a Build button on the top of the IDE screen and have it automatically tranfer to the Arduino automatically.  I might be asking too much, but it is worth bringing up.

So here is another project I’d like to attempt.  I want to write an ASP.Net web application that acts like the Arduino IDE, including the color coding for recognized terms.  I also want to add in automatic indentation and click-to-add code (insertion of where/for loops and other skeleton code).  It will also include a funtion to upload a zip file that includes new libraries.

Initially, I think that the user will need to copy and paste the final code into the Arduino IDE for compilation and uploading to the Arduino board, but later attempts will try to skip this requirement.


Only one year until next Halloween

Here we are on November 1st, 2011.  As the sugar rush from last night dies off, it is a good time to begin planning for next year.

Halloween is a big deal around our place.  Carving pumpkins has always been an epic ritual for my wife and me.  We have done everything from adding Christmas lights as hair to dressing up our jack-o-lanterns in a tux and wedding dress (the year we were married).  Below is last year’s entry: my carving of Yoda.

2010 Jack-o-Lantern

Sadly, this year we did not participate.  That means that next year, we have to go even bigger to make up for this year.  I’m thinking animatronics.

I purchased a voice recording unit from Radio Shack a few weeks ago and wanted to use that in this year’s pumpkin, but I decided to hold off until I could implement it in a grander scale.  While doing some brain storming, I was suddenly struck with a memory of childhood: eating pizza at Chuck-E-Cheese with a half-dozen animatronic animals singing happy birthday to me.  The part of this memory that has always stuck with me is the eyes.  Always watching!  The livelyhood of the characters came from the eyes darting back and forth.  The rest of their movements were merely gravy.  To me, moving eyes is the key to animating objects.

My goal for my jack-o-lantern was to add eyes that would move in a way that is relevant to the situation.  Anyone can move an eyeball around, but making it move in a way that produces the sense of the object “watching” you is what will make this project worthwhile.  I decided to make my pumpkin’s eyes watch the trick-or-treaters approach the door as they walk up the steps.

In this case, I don’t plan on moving the eyes up and down, but rather just left and right.  In order to find the rotational degree of each eye ball in reference to where the kid is on my sidewalk, there are two variables that need to be considered: 1) the angle made up of where the kid is in relation to the plane of the jack-o-lantern face and 2) the distance between the kid and the plane of the face.  Once I have these variables, I can rotate the eyes left to right in order to point both eye balls directly at the kid.

Here is the approach…

1) Determine the angle and distance variables using a servo-mounted ping sensor.  Ping sensors are ultrasonic distance measurement sensors that send out an ultrasonic tone and then measure the time it takes to receive the echo.  The shorter the time, the shorter the distance (since sound moves at a reasonably stable speed).  By mounting the sensor on a servo and the servo in the dead center of the top of the pumpkin, the sensor can be wiped back and forth over a 180 degree range.  The servo will start at 0 degrees (facing the left ear) and take a distance measurement.  Once the distance has been measured, it will move 1 degree to the right and take another measurement.  This will continue to 180 degrees (right ear).  With distances measured on all 180 degrees, the angle with the shortest distance is picked as the one with the nearest target.

2) Eye balls made of ping pong balls (maybe with LEDs inside?) are mounted on independent servos (one for the right eye, one for the left).  These are mounted inside of the pumkin with the eye balls exposed through the jack-o-lantern’s eyeball sockets.  Two measurements are taken: L and R.  L is equal to the center of the left eye ball to the center line of the jack-o-lantern (on which the ping sensor’s servo is mounted).  R is equal to the distance from the center of the right eye ball to the pumpkin’s center line.  These will be used later.

3) The three servos are controlled by an arduino that is mounted inside the pumpkin.  Since we are using electronics, the traditional candle used to light up the pumpking will need to be replaced with LEDs, but that gives us flexibility for other special effects down the road.  Maybe RGB lighting that fades from one color to another?  We’ll see how that turns out.

4)Using the law of cosines in the code, we can determine the angle of each eye based on the angle of the ping servo and the shortest distance measured, being that the angle and the distance are related at that point of the distance sweep array.

Example of calculation

Let’s say the D is the distance measured between the kid and the pumpkin by the ping sensor.  R is the distance between the center line of the pumpkin and the center of the right eye.  P is the angle of the servo at the time that D was measured.  We want to find X which is the angle of the servo mounted to the right eye ball.  To know X, we need to determine the distance of the leg of the triangle opposed to angle P.  In a right triangle, this would be done with the standard pythagrean theorem.  Knowing that it is unlikely that P=90 degrees, we need to use the more extensive one.


Or in our case:


With H determined, we can redo this same equation to determine the angle of x.


Using arccosine, x can be determined to provide the angle of the right eye ball.  The same method would be used for the left eye ball.

5) Once the distance is less than a specified value, the voice recording unit is activated to play back the recorded message.  Personally, I’m thinking of something like, “You aren’t coming for my candy, are you?”  Currently, there is a momentary button used to trigger the playback.  I plan to remove the momentary and replace it with a relay that is controlled by the arduino.  A relay might be overkill, but I also like the idea of isolating the circuits.

As I mentioned earlier, this would all be processed by an arduino.  Below is the shield I designed to interact with the servos, ping sensor, and the relay for the sound module.