Vagrearg Logo  
1D Pong
Yet another one, but a nice one
Imagine you work in a new building. A building with a lot of white halls and walls and without any charm, any whatsoever. Then, you have a lot of teenagers walking in that same building. Teenagers who are there for games, that is one of the things we teach down there.

Wouldn't you just hate it to go through those halls and look at the walls?

Time to make a game. One that makes noise and lots of blinkenlights. A game with interaction and really, really simple. The simpler the better. Lets make 1D Pong.

I had already ordered some WS2812B LEDs last time from China and also some cloned Arduino Pro Mini boards. There were, from an older project, some arcade buttons and that should be enough. A quick look through the wood-working lab recovered a piece of MDF of just the right size. A wallwart power supply from the junk box and wires are everywhere in the electronics lab. Hooray! All pieces together.

The piece of MDF was milled on the back with a groove over the complete length and then some on the middle (and drilled too, all by my colleague). The groove, a reverse-V, holds the wiring and a few clippings of plastic hold the wires in place. The whole piece of MDF was painted black. The electronics design is so simple as everything is done on the Arduino. It is a matter of wiring it up and load the code. The micro controller was mounted on a piece of perf-board and covered with a piece of acrylic for protection. I whipped up a quick design with holes for the laser-cutter.


The arcade buttons are rather deep. The solution was to mount them on some acrylic plate raised enough for the buttons to go through the base but not all the way. The advantage of the acrylic is that it also protects the ends of the LED strip. The holes were drilled large enough to slip some extra wires through from the LED strip. The strip was glued in place with some double-sided sticky tape.


The schematic diagram is also available as PDF. As shown, it is quite a trivial design. The hard part is the software.

The software is available as a zip-file The LED strip driver is from Adafruit's Neopixel library with a few modifications. The timing is required to be rather good. The update of 60 pixels with interrupts disabled takes too long and you lose a timer interrupt, which is boldly compensated. The second change is the addition of HSV color-space pixel setting. It makes the rainbow a bit easier.

[update 2021-01-26]: Newer software version: Somehow this version never got uploaded. It got my attention because this HAD project shows a remake using the software from this site and was presented at HAD's blog.
This newer software version, created for a remake of this project Down Under, adds sparkles (twinkles) in the display when you boost the ball. It makes boosting visually more interesting and acts as a distrction to the opponent. This increases the value of using the boost for the player. This is also the version that runs at the school, where it still is used by the pupils (well, when we are not in lockdown, that is). [end update]

The disabled interrupts of the pixel update also interferes with Arduino's sound generation. The tones are generated using timer1 directly and outputting a square-wave on the OC1A output, driving a buzzer. Using the timer makes the sound independent of any software and it doesn't "click" or "drop" anymore.

The program is written as a state-machine. All effects, movement and gameplay is organised through a distinct set of states driven by events. Events can be button events or timer events. An idle-show is displayed when no one is playing (see images below). Score is displayed on the LED strip for each side, using red and green to distinguish between them. The score is visible throughout the playing at lower intensity.

The game is made interesting with several features. Firstly, the ball will become faster and faster for every time it is hit back and forth. Secondly, the ball can be hit back within a blue "zone" and will be returned faster the longer into the zone you let the ball come. This is, of course, at the risk of hitting too late. Thirdly, you can boost the return by holding the boost-button down while hitting. The cost of a boost is reduction of your hit-back zone.


The funny part of the whole project was showing it to others. I put the finished game on the table in the teacher's lounge and waited and looked what would happen. Well, nothing happened! Most people just walked by and barely looked. Only very few dared to push a button. Wow! Where are the people who look with their fingers. The funniest reply I got when I asked was "I might break it or it may shock me". So much for trust ;-)

Time to test it on the teenagers... The game was put in the canteen where most will walk through. Again, most just looked barely and walked by. There were a few more that dared to push a button, and, eventually, also a few who started to play. I was amazed how few were looking with their fingers. Maybe we have too many well-raised consumers and too few tinkerers. Time will tell.

But, not all was lost. Once I got it hanging on the very white wall, in a place where you cannot miss it, it was being used. Now, after a couple of weeks, it seems to be a hit, both literally and figuratively. There are now people asking questions and even an off one complaining (>grin<). And, of course, an image of some boys having a lot of fun.


What is not shown is the crowd that stands behind me. At first, people were afraid to push on the buttons and just play. But, after a couple of days it is being more and more used. Soon we need to do a real competition. And, for the record, at the time of this writing, I have not yet been defeated.

I'll make a video soon.

Posted: 2015-05-25
Updated: 2015-05-25

Overengineering @ request