Introduction: Octarine: an Arduino Powered Color Matching Game With WS2812 RGB LEDs

Octarine, the colour of magic. It was alive and glowing a vibrant and it was the undisputed pigment of the imagination, because wherever it appeared it was a sign that mere matter was a servant of the powers of the magical mind. It was enchantment itself.

But Rincewind had always thought it looked a sort of greenish-purple.

— Terry Pratchett - The Colour Of Magic

All the colours are enchanted and you have to free them one by one. Three magic spells will help you in you in your quest.

P.S. In this project I use extensively binary operators and binary masks, so it may be used by Computer Science educators for purpose of Boolean logic teaching in amusing gamified way.

Supplies

1x Arduino Nano/Uno or other compatible board. The project actually uses 5 digital pins and less than 6KB of memory. So Attiny85-based board should also work well.

4x tactile buttons. If you prefer, you may use sensor buttons instead.

1x WS2812 LED strip or bar with 8 controllable RGB LEDs.

1x breadboard or PCB prototyping board if you prefer.

Breadboard Jumper Wires.

Step 1: Game Rules

The game interface features 8 RGB LEDs. The goal is to make them all shine with the same colour. It's red in first “world”, orange in second, yellow in third, etc.

There are 3 main buttons. Each of them changes the colours of four LEDs according to binary mask. For example, the first button has mask 11110000. It means that it changes colours of first four LEDs. There is also a “Shift” button which inverts a mask. If player presses Shift+First button, the mask would be 00001111 and four last LEDs would be affected. Colours are being changed cyclically.

The attached image describes all the masks.

Step 2: Levels Design

The game consists of “worlds” eight sublevels each. First world is “Red”, and all the LEDs here may be in just two states: blank and red. In each sublevel more shuffle steps is applied, so the difficulty increases gradually. When you pass a world (i.e. all the sublevels), you rescue the next colour. So in second (“Orange”) world all the LEDs have three states: blank, red and orange. That is to say, each next world is more challenging than previous.

What happens in 8th (“Octarine”) world… well… pure magic.

Step 3: The Circuit

It depends on particular board you use, but I strongly recommend using external power supply for LEDs.

I used pins 2, 3, 4, and 5 for buttons. If you use another microcontroller or pins don't forget to modify it in the program code.

Step 4: The Code

Here you may find the latest version of source code.

Step 5: Testing

Step 6: So, What's Next?

You may have noticed that the game actually does not have 8th (Octarine) world. It was made intentionally. Magic… is not something supposed to be exactly reproduced.

I encourage you to build your own 8th world. For example, you may make player arrange rainbow-coloured array instead of monochrome or implement cells with changing colours. It's up to you. Do your own magic in your own way.

LED Strip Speed Challenge

Participated in the
LED Strip Speed Challenge