A few days ago I caught wind of the #BringYourBuild competition being run by Maplin here in the UK. This was to celebrate the 11th burthday of the Arduino platform. All you needed was to submit an Arduino based project, either via social media or (preferably) in store.
I don’t do much with Arduinos but I have an Adafruit Trinket, that’s great for little projects like this, and I paired it with a Pimoroni UnicornHAT. “What witch craft is this?” I hear you cry? Yes, I know it’s designed to sit on top of and be driven by a Raspberry Pi, but it has three blank headers to allow direct access to drive the UnicornHAT (marked VIN, DIN ,GND on the underside). Wire these up and the Neopixels are yours to command!
With only an 8×8 grid to work with I opted for a simple object avoidance game which I’ve called “Purple Rain”. It uses a linear potentiometer to control the position of the player via the map function to relate the resistance to the 0-7 needed for the horizontal pixel. This is checked every few milliseconds to see if the potentiometer has moved and thus the resistance has changed.
The “rain” is randomly generated, with more “drops” or pixels being added as the game progresses. The speed also increases over time by reducing the number of cycles between movements of the “board”.
I also included an idle screen between games which is just randomly generated colours on random pixels.
— Maplin Farnborough (@Maplin_FNB) March 28, 2015