Fun with the Arduboy
I've been having a lot of fun with this open-source game console, the Arduboy.
It's effectively an Arduino Leonardo in the guise of a minimalist GameBoy: 1.3" OLED display, D-pad+A/B buttons, and battery in a credit-card sized enclosure. Plug a cable into the USB port at the bottom there to swap the game or upload your own.
I think its limited specs are a blessing in disguise. The small screen and few buttons makes it kid-friendly (well, about as much as a video game can be!), and the tight program space is an effective guard against overengineering.
Maybe I'm jaded from slingin' websites for so long, but the tactility of my little idea on a device that fits in my pocket is deeply gratifying. The Arduboy makes for a great onramp into the world of embedded software, even if you're not out to make the next Mario.
Games Things I have made for it
Arguably, none of these are games, despite the Arduboy being a game console. C'est la vie.
Any Kind of Car and Any Kind of Truck (Any Kind of Any Car and Truck)
My first offering is "Any Kind of Car and Any Kind of Truck (Any Kind of Any Car and Truck)," made for my vehicle-obsessed child and named for an open challenge that I can draw him any kind of car and any kind of truck.
Play it right now!:
Play "Any Kind of Car and Any Kind of Truck" ►
(For this and the other emulated games here, click a couple times to activate, then use arrow and Z/X or A/S keys for buttons.)
To play:
- Button B randomizes the vehicle's parameters: cab/box/wheel size, trunk/hood ratio, and the distance between wheels. The score tally increases with each randomization.
- Button A toggles the title and theme song, something so important it couldn't be contained to just the game's start.
- The direction pad moves the vehicle around and makes it jump, so I guess it's got hydraulics!
- A+B+Up maxes out the vehicle specs. A+B+Down minimizes them.
My sketchbook reminds me I was first thinking of making it like a mix-and-match spinning block toy:
A two year old is kind of a great target demographic. The reward of their joy is immediate and they don't need any real complexity. Make all the buttons do something and the sounds fun, and you're good. I could have spent more time adding features to satisfy older players or do any of the code TODO
s to satisfy myself, but he wouldn't have noticed, so why bother?
Links: playable demo, source code, forum discussion
2D6: Dice Roll Distribution Visualizer
Speaking of randomness...
Roll a six-sided die. Each of its possible values is equally likely, yes? In other words, a roll of one will occur just as often as two or three, etc. Now roll two six-sided die ("2D6," in game parlance) and add their values. Are their sums also equally likely?
The answer is no, they are not. Since the average roll from a 1D6 is 3.5 and 2D6 is twice that, the most likely roll from a 2D6 is 2 × 3.5, or seven. The likelihood of other rolls diminish as they stray from seven, with two and 12 being equally least likely.
And theoretically, if you graph that, you get a kind of bell curve.
Source: https://tadeohepperle.com/dice-calculator-frontend/?d1=2d6
So this is basically a math exploration tool to roll digital dice up to a thousand times and chart their results. Does practice match theory? You can additionally change the number of dice and how many sides they have, from two-sided coin flips to twenty-sided dice. How do the number of dice and their sides change the shape of the curve?
I promise it's more fun to play with than it sounds...
To play:
- The menu screens flow sequentially. Button B advances and A goes back. Use up/down for selection. Go back from the title screen for credits.
- The final screen shows roll results, where up/down slides between the graph and selected raw numbers. Press A to go back.
- Holding the "roll" button for a second to auto-roll, and hold the right button while rolling to 10x rolls. You'll hit the arbitrary 1000 rolls cap pretty fast.
Unordered production notes:
- A math utility on a 128x64px screen is a fun design challenge. How much can be shown without being cumbersome? How can I strike a balance between correct and accessible?
- There are lots of playful little touches like the dice spinning out of sync and bouncing windows when you've reached their limit. It uses the same sound effects as "Any Kind of Car...", much to my child’s confusion. It is a very game-like non-game.
- The Arduboy actually has two pins connected to its buzzer speaker. Some games will use these to for two tone polyphony, but sending the same tone to both pins makes it louder. This is how the HIGH/LOW/NONE sound volume control works.
- It is an okay dice simulator but not the most polished. And also not withstanding the bias caveat mentioned below...
- Abandoned ideas
- I briefly pursued a UI where you horizontally scroll left to right, since the dialogs are sequential. Wasn't worth the memory or overhead.
- The code has a
drawEquilateralPolygon
that I experimented with for other dice shapes like a four-sided die's triangle or the pentagon from a 12-sided die. Making odd shapes have text and fit together nicely was well outside of scope. - The dice could animate more, bouncing into their container and off of each other before settling into place. Can you imagine?!
Sketchbook:
Brute-forcing dice roll distributions feels very much like a dumb way to do a smart thing. Right up my alley!
Links: playable demo, source code, forum discussion
Songs for Desmond
My opus. From its readme:
One thing nobody tells you about being a parent is that, as you go about the day taking care of your kid, you absentmindedly sing little songs about everything they do.
The other thing nobody tells you is that the songs... are good.
"Songs for Desmond" collects ours into a kind of 1 bit love letter: a 27 track album of minimalist square wave melodies, released exclusively on an Arduboy game console that he can carry around with him.
I believe it is the first kids songs album to be released on the Arduboy.
To play:
- Up/down change volume
- Left/right change track
- A to stop
- B to play
My sketchbook drawings on this one are more about a standalone digital music box I keep thinking about. If I ever end up making it, it'll have something to save my ears from high pitch tinny square waves. (The Arduboy's 12mm piezo is not ideal for playing 5min straight of music.)
Unordered production notes:
- Intro animation is from a video of my kid walking around, converted to sprite sheet with FFmpeg and cleaned up in Pixelmator.
- UI is a simple music player. Instead of album art, the intro sprite is cropped to a square and synced to each song's tempo.
- Melodies were written to MIDI with Signal, then compiled en masse for the Arduboy with a
./compile_songs.sh
script. - Again, sound volume is accomplished with the two pin buzzer trick. I considered a bassline for the second pin but abandoned it for simplicity and file size. Doubling the music data would have pushed it over the device's program space.
- The internet is full of jerks. Forums (and especially forums for technical topics) collect the worst of them. The Arduboy community, however, is a pleasant, encouraging oasis. It is the only forum of strangers I have joined and is a major reason I got into this at all.
- One user, @Pharap, was kind enough to offer a code review and advice on memory saving techniques. My C++ experience is zilch, so it's good to get some other eyes in there.
- Songs include the theme for the car game above and half the game ideas below.
Links: playable demo, source code, forum discussion
Development process
For development, I edit in my regular code editor then run a run.sh
script to automate the Arduino CLI compilation, Ardens emulation, and final uploading to device. For now, each repo has its own copy of this script.
./run.sh -h
CLI wrapper around Arduino and Ardens
Usage:
./run.sh -h Show help and exit
./run.sh compile Compile
./run.sh emulate Emulate
./run.sh dev Compile and emuluate
Looped! Quit emulator to refresh
./run.sh deploy Compile and upload
Default port: /dev/cu.usbmodem143101
./run.sh deploy -p PORT ^ with arbitrary port
Run 'arduino-cli board list' for list
Of course, editing and uploading in the regular Arduino IDE also works perfectly fine, if less automated.
Ardens does profiling and debugging too, but the emulating alone makes it a must-have for Arduboy development.
Game idea doodles
A great thing about a new tool is that you start seeing places to use it everywhere, like it becomes a creative outlet or canvas or something. "I wonder what this'd be like as a game!" you say as you draw your little drawings.
- This Town's Got a Lot of Construction
Job by job, construction trucks build a city. (Theme song: track 25) - Street Sweeper or Trash Truck
Clean/pick up all the trash on the street before your truck runs out of gas, a la Pac-Man. (Theme song: track 16) - Pixel art editor
Simple but usable pixel art program on native hardware; output hex code displays on screen for export. - Bouncing a Bouncy Ball
Physics playground for bouncing a ball, with settings like the old Incredible Machine game. (Theme song: track 11) - Binary Trainer
Race against the clock to convert increasingly difficult numbers between binary and decimal. Hard mode: hexadecimal. - Fair Share
Cut food at an ever-growing party of impatient guests envious of unequal portions. How well can you divide a circle into three pieces, a rectangle into five, etc? This one has some actual pixel concept art! - Higher Lower
Two tones play — is the second one higher or lower? The more you get right, the harder it gets. No screen needed to play. - BoyBoy
A handhold game console with a text character display? Name is placeholder.
Who knows if I'll make any of these!
What's next
- The Playdate from Panic is next on my list to tinker with. I have one now and like it a lot, though it's a little too fancy for unsupervised play.
- ArduboyFX, the successor to the older version that I have, has space for more games and can do grayscale colors. I'm sure I'll pick one up soon enough.
- Another gadget I'm looking at is the PyBadge from Adafruit. It has more bells and whistles but you're on your own for the enclosure and battery. It's more a prototype board than an end-user product.
- The Arduboy Mini has similar enough dimensions to the Scout's battery holder that I'm tempted to build an enclosure for the two. It could work!
- Oskitone is going to put out a game...