Back to the hardware

A project log for Trinket Watch

A watch with an OLED display, powered by a Trinket

davishdavish 12/25/2014 at 05:100 Comments

After a long day of traveling I come home, check Hackaday, and realize that I won the fourth drawing for the EDC contest! That definitely made my day. To follow up my "victory" (if you can call getting randomly chosen a hat a victory), I loaded up all the code that I wrote while I was away (I ported the JS to Arduino's Processing language on the plane). The analog clock face works just as well as the digital one.

For Pong to work, though, I needed to wire up the three navigational buttons. I used a lesser-known digital mode on the Arduino called INPUT_PULLUP. It pretty much does what it says. It pulls one end of the switch to 5V, and the other one's connected to ground. Though the input is flipped (LOW is closed and HIGH is open), I don't have to connect the switch to 5V, ground and the input pin, which will save space in the final design. I wrote a quick debouncing function, booted up Pong, and lo and behold, I got a little arcade action on my tiny screen. There's one bug that wasn't there in the JS version, though: the ball doesn't bounce off the bottom edge of the floor; it just kills its own sideways velocity. Well, there's always time to fix that. Only feature that's missing is showing the computer's and the player's scores, but that again can wait.

The next thing I decided to tackle was how someone will switch between "apps" on the watch. At first I tried having different modes for time, and games, and other things that you would cycle through by pressing two directional buttons (one "up" or "right," the other "down" or "left"), and then go back to a main menu by pressing a select/back button. In the code, this got a little complicated and probably would have involved pointers for the different menu variables, so I decided to take out the "main" menu and just have the middle button cycle through each of the modes; in Pong mode, the directional buttons just play the game, not cycle between anything. In the timekeeping mode, pressing either directional button switches between analog and digital timekeeping. The one thing that's a little bothersome is that it takes longer to switch from digital to analog than from analog to digital. Here's a video of everything in action:

I already have the code for a stopwatch, which will probably be a separate mode. If I have time to integrate the small vibration motor I bought, then I'll add a fourth mode for an alarm.