2011-04-22

Hippo Paint

My three year old niece likes to sit in front of Google Image Search and look at pictures of dinosaurs (and frankly, who doesn't?). Every once in a while there's a coloring book style picture and she wants to paint it. The best I could come up with on short notice was to print out the picture and give her crayons. But obviously there had to be a better way.

Enter Hippo Paint.



It should work in all modern browsers (it even works in IE9). While making this I could clearly see that JavaScript engines in browsers really are getting faster (for example there's a big difference between Firefox 3.6.x and 4.0), but you still have to make all the trivial optimizations like function inlining or common subexpression elimination by hand.

I also encountered an interesting bug that only manifested itself in Opera. I had a piece of code that looked something like this:

var img = new Image();
img.onload = function() { /* ... */ };
img.src = '...';

And sometimes the onload handler function wasn't getting called (even though I could see that the image was successfully fetched from the network). After a frustrating debugging session I noticed that it only happened when fetching the image took longer than usual (say, more than a second). It turns out that it gave Opera's garbage collector enough time to kick in and collect my img variable. I don't know if other browsers don't have as aggressive garbage collectors or if they think that the existence of an event handler is enough to mark the variable as still needed. Anyway, the solution was simply to move the variable to an outer scope.

I hope you and your kids have as much fun using Hippo Paint as I had making it.

2011-03-30

Pivot screen fun

I used to think pivot monitors were only good for playing Pac-Man in portrait position. But why restrict ourselves to just the landscape and portrait positions?



Since the monitor only knows two states, I had to resort to a little trick. I attached my phone to the back of the monitor and wrote an application that broadcasts orientation data from the phone's accelerometer on the network. On the computer, another application receives the data and rotates the teapot accordingly. (Here's the source code to the phone application and the teapot application if you're interested.)

What I really wanted to do was to make the desktop rotate with all the windows. I think it should be possible with Compiz, but I'm pretty sure it would prove difficult enough for me to lose interest halfway through. So, a teapot for now.

2011-02-17

Morse Code Reader

I wanted to make a Morse code reading application for some time now. Here's my first attempt, it listens to the signal through the phone's mic and translates it to text:



I'm sure there are all kinds of advanced signal processing techniques that I should be using, but for now I went with the simplest, most naive approach. And it sort of works, except when it doesn't. What I do is I keep an exponential moving average of the signal's volume and I decide that the signal is currently "high" when the average is above a threshold and "low" when it's below it. The threshold is set based on recent peak volume. Then I try to decide what the length of a dot and a dash is, interpret the input accordingly, and finally translate the dots and dashes to letters. The application adapts to changing volume and speed within reasonable limits (it should work up to about 40 WPM).



I was hesitant about putting the application on Android Market, as I only tested it on my phone and it quite often fails at translating Morse code. Then again, it's not like I have anything to lose by getting 1-star reviews and insulting comments, so why not.

Here's a Market link.

2011-01-28

Page turner Mark II

I have improved my initial page turner design. Thanks to a third motor that repositions the rubber wheel between the left and right of the book, we can now turn pages in both directions!



The device is still manually operated and the problem of sometimes grabbing more than one page remains. But it is now less of a problem, because if we go a few pages too far, we can always go back.


2011-01-27

Automatic page turner

Reading books is hard enough as it is. They're often long, boring and some don't even have any pictures in them. I decided to at least eliminate the physical effort of turning pages and constructed this little device:



At the moment it's not entirely automatic as I'm still controlling the individual motors manually (via Bluetooth from my phone, which is off-screen, because I'm also using it to shoot the video). The setup requires some tweaking for the exact size of the book and probably only works for a certain range of pages in the middle of the book. It also still sometimes grabs more than one page. But hey, it's a start. There's obviously room for improvement, for example it would be nice to be able to turn the pages in both directions. (Update: Here's an updated version that does that.)

2010-11-12

NXT Remote Control

Two of my favorite toys right now are my Lego Mindstorms set and my Android phone. And thanks to the Bluetooth protocol I've found a way to combine them. Behold!



Since the video is quite blurry, here's a better view of the application's interface:



The third control scheme (not pictured), which I like to call the tank mode, allows you to control each motor separately and works best if your phone has true multitouch support (not just pinch-to-zoom).

Now I'm not saying my application is very unique, there are at least two others on the Android Market that do the same, including an official one from Lego. But hey, it's mine!

If you'd like to try it, below is a QR code that you can scan from your phone (or if you're reading this on your phone, just tap the code). And here's the application's AppBrain page. (It's free of course.)



Finally if you'd like to see the source code, it's over here at Google Code.

2010-10-23

Paper clip spinning top

Today I'm going to show you how to make a spinning top from a paper clip. If you have a three year old niece or nephew, this is a trick you must learn.



You're going to need a paper clip and a pair of pliers. Also some cylindrical object is helpful, but not strictly necessary (I used a screwdriver handle). The paper clip can be any size, I used the bigger kind for demonstration, but the smaller ones work, too.



Supposedly the angle between the spokes must be 53 degrees for the center of gravity to be on the axis, but in my experience any roughly pac-man-like shape works. With a bit of tweaking you should get a top that spins for at least 30 seconds on a reasonably smooth surface.