Added to the labs, a proof of concept page turning button: https://github.com/twstokes/labs/tree/master/pageturn
Category: Arduino
A Tree Divided
See the GitHub Repo!
Idea
Every year Clemson plays USC for their state rivalry game. I pull for Clemson and my wife pulls for USC, so we’re what you call a “House Divided”. Since this game takes place on or after Thanksgiving, it’s a great time to incorporate the LED Christmas tree and troll my spouse!
The tree works like this:
- When a team scores, it plays their fight song and lights up with their primary and secondary colors.
- The lights on the tree are distributed by the ratio of points. When it’s tied, they each get 50% of the lights. If Team A has 2/3 more points, they get 2/3 more lights in their color.
- The ring under the star at the top of the tree is the color of winning team. If they’re tied, it’s split.
- When the game is finished, the tree is the color of the team that won.
Software
I used Golang for the software since I primarily write code in another language and want to get better at it. It makes use of various interfaces to aid in testing and abstration:
- The Fetcher interface gets the latest game state from a data source
- The Player interface plays audio at the given path
- The Illuminator interface controls a light source (in this case the LED tree)
The source code for a local data fetcher is included in this repo only. The remote fetcher I built may or may not have used an API meant for this sort of consumption. It simply fetched from a remote data source, unmarshalled a JSON data structure, and supplied what the Fetcher interface needed.
The code runs on a Raspberry Pi and communicates with the MCU via serial. An iHome IBT63 speaker is used to play audio from the Raspberry Pi. I didn’t use the Bluetooth connection and instead used the shared power and audio connector, plugging one end into the RPi’s stereo jack and the other into the USB port.
I cross-compiled from my Mac using the rpi.sh
script in the executable’s directory.
Firmware
- Uploaded using PlatformIO
- Runs on a NodeMCU ESP8266
The Rover got its own iOS app and I implemented a neat way to control the camera servos.
Before you ask "why" I'm going to go ahead and ask "why not". #Arduino #RaspberryPi pic.twitter.com/MVTJNCD7Ek
— Tanner Stokes (@TannerStokes) August 18, 2018
Rover progress
Once I win the lottery this will be all I do all day long. pic.twitter.com/F0TAEJDyEP
— Tanner Stokes (@TannerStokes) March 27, 2018
The latest obsession
See the GitHub repo for a parts list, wiring diagram, and Arduino code.
The time has come: My 2009 Mac Pro has been retired and replaced with a 2016 MacBook Pro. Not only has the temperature in my home office dropped about 4°F, but I can now run the latest macOS, Xcode, and Docker, which I need for work (for that money stuff). I held on to the Mac Pro as long as I could, though, and I can confidently say that the “cheese grater” desktop is the best machine I’ve ever purchased.
A new setup presents new challenges. One issue I’ve found is switching states between “docked” and “undocked”. I put this in quotes since Apple doesn’t have a true docking station solution. Because of this it’s way too easy to rip out the USB connectors when “undocking”, which could lead to a dirty removal of a volume (e.g. something hasn’t been flushed out of cache to the actual hardware yet and data is corrupted / lost). Since I have a Time Machine drive connected at my desk, this can happen if I don’t remember to eject it from Finder.
I think this process would be easier with an external button to do the work for me before disconnecting the laptop. Currently in the hack phase, I’ve wired up an Arduino with an RGB pushbutton that communicates to a macOS app. When it’s time to undock I simply press the button to unmount all volumes and get visual feedback that it’s safe to pull the plugs…
I plan to do a more thorough write-up on my plasma-ball project, but for now here’s the video, some pictures, and a link to the repo.
Experimental code: https://github.com/twstokes/arduino-gyrocube