Musings of a Fondue

A Simple Arduino Game

Original Date: August 9, 2014

I made a game.

It’s a combination of two tutorials. The game mechanics are based on the LED Game tutorial by PyroElectro. The use of Processing to show the score and time is based on Jeremy Blum’s tutorial.


  • Press button when middle LED is on
  • Points get per hit depend on how fast the wave is going (1 to maximum of 7)
  • Speed of the wave increases as time elapses. It is also adjustable at any time with the potentiometer
  • At 30 seconds remaining, player gets alerted (LEDs blink and Processing display starts pulsing)

Arduino game

This took a week! The idea was simple but wrapping my head around how to actually code it took some time. I was surprised at this, but learned a lot in the process.

Hardware interrupt vs. continuous polling,

When the push button is pressed, you want something to happen( for example calling a function to check if the middle LED is on ). With a hardware interrupt this is easy. However to use a hardware interrupt, you also need to use hardware debouncing for the push button and I didn’t have the necessary components on hand. I opted to instead use a simple delay() to account for bounce, and continuous polling to detect if the button was pressed. That is, every 100 seconds or so, I called checkPress() to get the state of the button (pressed or !pressed).

Here’s the Arduino code for the game
And the Processing code

Make sure to checkout both Jeremy Blum’s and PyroElectro’s full Arduino series on YouTube. They are great for getting started and for ideas.

Also, if you have an idea, go for it. It might not turn out to be as straight forward as you thought but YOLO the journey is often worth it.