The Automated Patriot


[pey-tree-uh t, -ot or, esp. British, pa-tree-uh t] noun
1. a person who loves, supports, and defends his or her country and its interests with devotion.

I always enjoy timeless American exhibitions of patriotism, but even more so I appreciate juxtapositions of those displays. What is the opposite of an awesome fireworks show? How can the flag, a symbol that is eagerly devoted to supporting its country, be disassociated from human behavior and be devoid of emotion? An idea kept running in my head over and over, I imagined a waving cocktail sized flag, while the Star-Spangled Banner plays on low quality crunchy audio. Combining my Arduino knowledge and the Sweep demo sketch, I mashed together two Digisparks to create this programming abomination. Some ideas just need to get out of your head as soon as possible.


I had little experience using servos, but I knew that servos were small motors that moved things, so this couldn’t be too difficult a task to handle. The first purchase specifically for this project was a box of 144 American Flag Picks, the heart of this operation, made in China. For the brains of this I figure using Digisparks would be perfect, they’re incredibly small Attiny85 microcontrollers that should be able to handle playing a song while moving a servo. For audio capability either a speaker or a piezo buzzer would work, I settled on a small 2in speaker with a ripped paper cone. To house this project I recycled a gray enclosure with lots of holes from previous builds.

My electronics bin had a few micro servos that should easily handle the flag waving duties. Getting the servo to behave properly was a bit more complicated. I started by attaching one to an Arduino and uploading the “Sweep” sketch to swing a servo 0-180 degrees. Just like in all good programs, slight modifications usually caused unexpected gear-grinding results. I soon realized that micro servos quality can vary wildly, and in the future it’s worth using the premium models. I settled on a Radio Shack (RIP) micro servo from a motor sampler pack, it behaves well enough. Attaching the flag to the servo was very simple, using a short piece of shrink tubing the flag was secure on the servo arm. Once I set the rotation degrees of the servo I was able to glue it on the inside of the lid on my enclosure, allowing it to rotate inside when finished.

For the Star Spangled Banner performance, I was completely out of my league with how to control this. Luckily I was able to find someone’s code to play the song with an Arduino, which when run through a Digispark causes some weird notes to drop. This is a feature, not a bug, and these were kept for added character. Still I had no idea how to handle the timing of the code to combine this with my servo actions. I started digesting NoDelay programs, trying to piece and patch my way to victory, but never was able to run both functions on the same Digispark. I settled on running the programs on separate devices, while not ideal this performed just as intended.

Instead of spending more time making the programming and construction perfect, I realized what I built worked exactly as I had expected with my initial idea. When first researching microcontrollers I learned they’re excellent for prototyping, and cobbling together this weird project from components I had lying around impressed me enough to be a successful prototype. While this is probably something I will revisit later, for now it will stand as a milestone of the start of my programming experience.