CWIID
YOU NEED
INPUT… INPUT…. INPUT!!!
Credit: https://github.com/azzra
OUR EXPERT
Les Pounder is associate editor at Tom’s Hardware and a freelance maker for hire. He blogs about his adventures and projects at http://bigl.es.
OUR EXPERT
Pi 4/4B+/ Zero W/2 W
Each button on the Wiimote returns a numerical value. In the tutorial, we ignored that and just searched for a specific button press. But what if you want to detect a specific combination of buttons? Well, Cwiid has us covered, but we need to do some maths. The up direction returns a value of 2,048, down is 1,024, and A is 8. So, if we press down and A together, it returns 1,032. The tutorial script returns the value of each button press, so all you need to do is a little maths for your chosen key combination. We can then use an additional conditional test to look for a specific numerical value in the buttons object. The value, once detected, could trigger an event, drift the robot around a track or world domination, your choice.
Les Pounder is associate editor at Tom’s Hardware and a freelance maker for hire. He blogs about his adventures and projects at http://bigl.es.
We are travelling back in time. Nine years, to be precise. That W was the last time we connected a Nintendo Wiimote to a Raspberry Pi. In this tutorial, we are learning how to configure a Pi to communicate with a Wiimote over Bluetooth. We’ll put the connection to use by constructing a very simple robot control script to spin motors connected to a Cytron Maker Drive motor controller. Using this script as a template, you can easily build a remote-controlled robot using the Raspberry Pi 4, 3B+, Zero W or Zero 2 W.
Cytron Maker Drive
We’ve provided an additional file, wiimote-control-numerical.py, which has an example of how to handle numerical input. The only buttons we don’t advise pressing are the power button and the - and + buttons. These cause the code to hard exit, but it doesn’t tell you that it has exited. The file is included in the download for this tutorial.