Recently, the new Plug-and-Make kit was introduced by Arduino. The advantages are very clear: no soldering, no breadbords. I gave it a try.
There is a simple game using seven buttons and seven LEDs arranged in a circle. (Unfortunately, this game does not have a name.) The only rule is: each press of a button toggles the state of the three nearest LEDs, and the goal is to set all LEDs on. There is a video giving you an introduction to this game. With the Plug-and-Make kit you get only one module containing three buttons, and single modules are not available. You might buy three kits and take all the button modules together, but this won't work, as each module has the same I2C address, resulting in an address conflict. (By the way, I own only one Plug-and-Make kit, and as the orange base board is already used for other projects, I created a copy of it using a piece of acrylic glass.) So, at the end of the day, I modified my plan: buttons won't be pressed by a user, instead the random function presses virtual non-existing buttons.
The next problem is the geometry of the LEDs. The pixel module offers even eight buttons, but they are not arraingned in a circle. So ignore the last LED and regard the first and the last LED as neighbouring each other as shown below.
This works pretty well, but you would not know which of the virtual buttons has been pressed. The easy solution: the LED, which sits next to the virtual button, has to be flashed. As soon as the button gets pressed, three LEDs are getting toggled, no problem. Now comes the tricky part: switching an LED on or off takes no time. I wanted to fade them smoothly. But it turned out that the Modulino Pixel library is very poor, compared to other graphic libraries. You have to work a lot to get it done. So far - so good. But games usually come to an end. How can the ghost, who pressed the virtual buttons, give you a reward? I wanted to show a rainbow moving across the pixels. But opposite to other libraries, the pixel library does not offer a rainbow function. So I had to code it myself.
If you own one of the Plug-and-Make kits you can connect the pixels module to the R4 WiFi, upload the sketch, watch the flashing LEDs and have fun, and eventually see the rainbow. How many random keypresses does it take to happen? Check it out!
Comments
Please log in or sign up to comment.