Based on the original project by Sam El-Husseini, this tiny Companion Cube takes care of your tunes – so you can take care of business! Play the next or previous song, or shuffle your Spotify playlist, using the BBC Micro:bit.
This project uses a Companion Cube planter I adapted from someone else's box design, which might also work as-is. I printed it with glow-in-the-dark PLA, put a plant in it, and then neglected the plant until it died. So it's a ghost, just like... well... no spoilers.
This project is great for Halloween, and also for celebrating 10 years of Portal!
Here's a video breakdown:
The codeFollow Sam's directions for the Javascript code; they are excellent and straightforward.
You'll need to modify the port in the Node.js file, or else your code will immediately quit. To do that, run: ls /dev/tty.*
...find the one with "usbmodem", and note the number. You'll put this in line 5 of the JS file.
For the MakeCode pieces, use Sam's file for the Micro:bit attached to your computer, and my modified one for the controller in the Companion Cube. It shows a little heart icon, and after showing the icon for the current command, it pauses for half a second, then returns to the heart. I think it's a little neater, and it matches the Cube design ^_^
To upload a MakeCode file to your Micro:bit, download it to your computer...
...then drag it onto the Micro:bit USB device.
The Micro:bit's LED will flash to show it's uploading, then you will probably get an unhappy alert from your computer, asking you to PLEASE EJECT DEVICES BEFORE UNPLUGGING THEM! This is normal. Click "Close" and forget about it.
The buildI printed my Companion Cube planter at 62mm wide. That makes the top perfectly shaped to support the "controller" Micro:bit on a little shelf! The side ridges hold it in place when you shake it, too.
I am powering it with a rechargeable LiPo battery from Adafruit. Mine is 3.7V and 500mAh. It plugs into the JST battery connector on the Micro:bit and sits down in the planter. The tension/friction from the wire is just enough to hold the Micro:bit in place pretty well.
The other Micro:bit (with the simple "listener" code) is plugged into the computer.
The music!The soul of the device!! Whether you're facing evil robot bosses, or building robot underlings, you need sweet tunes to get you through. Load up this playlist – not the public-domain weirdness I was playing in the video – and hack like a badass!
Comments