What do you get if you cross some Raspberry Pi powered robotics hardware, software from Viam, Pieces for developers, and confetti? An awesome conference booth demo! And a lot of mess (which our CEO kindly vacuumed up for us).
Introducing the Pieces confetti cannon
The goal of our confetti cannon was to provide a fun way for conference attendees to try out Pieces, in particular our snippet saving and sharing capabilities. Pieces is the long term memory for your entire developer workstream, so we wanted new Pieces users to experience first hand how it can be used to remember and share important code snippets that are augmented by AI.
By grabbing a shared code snippet, building it into a Flutter app, then running it, attendees at our booth could not only launch the confetti cannon, but would then be entered into a draw to win a Pieces hoodie (want one yourself? - check out our Pieces store).
How does it work?
This project was based around the confetti bot sample from our friends at Viam, with some Pieces magic sprinkled over it.
The hardware
The core of the hardware is a Raspberry Pi - my favorite IoT device. The Raspberry Pi is a single board computer - a full Linux machine that retails for $50 and up. Despite being only a few inches across, this packs a powerful processor and 2GB or more of RAM. This was originally designed as a cheap home computer for kids to learn to code on, but is perfect for makers and other hobbyists to build robotics projects. I have an 8GB Raspberry Pi 5 at home for example that I run LLMs on!
The Pi is used to control a battery-powered motor, all encased in a 3D-printed case. This motor is used to twist the launch mechanism for a confetti cannon - a spring loaded device that fires shiny confetti.
The software
To control the hardware, I used the Viam robotics platform. I’ve been involved in the IoT scene for years, and appreciate how quickly I could deploy a hardware project using Viam. I installed their server on the Pi, configured the hardware via their web app, and was able to control the motor in only a few minutes. No actuator code to write, no messing around in C++, all I had to do was set up a project, add the hardware I had, then enter some GPIO pin numbers and other settings in their web app.
Once I had this set up, it was time to build a controller app. I wanted to build something that the attendees at FlutterCon could play with. My goal was to provide the code for a simple Flutter app (this was for FlutterCon after all) that had a single button you tapped to launch the confetti. This code needed to be small enough for someone to understand quickly, and not contain any of the Viam API keys or other secrets.
My solution for this was to run a web server on the Raspberry Pi written in Python with the Viam Python SDK. This web server would connect to the Viam service on the Pi via the Viam cloud. I could then expose this web server to the outside world using Ngrok, so as soon as the Pi was connected to the conference WiFi, anyone with the URL could access it. I then wrote a small Flutter app with a single button that called the web server.
Once the Flutter app was set up, I used Pieces to save the main Flutter app code as a snippet. Pieces automatically augments code snippets with AI, and you can manually add other details to the snippet. I added instructions on how to use this to launch the cannon to the snippet, along with the AI-generated metadata. You can find the code using this share link. And no, the cannon is not running and this code needs a key I’m not going to give you, so you can’t surprise me by setting off the cannon in the middle of the night. 😝
The launch process
To launch the confetti cannon, an attendee needed to do the following:
- Install Pieces
- Save the shared snippet
- Create a new Flutter app
- Delete the contents of the
main.dart
file (this is the main startup code of a Flutter app) and replace it with the saved snippet - Add a key that we would provide at the booth
- Run the app
- Hit that confetti button!
We filmed a short video showing this entire process:
Want to try this yourself?
If you want to try this yourself, I created a GitHub repo with:
- A list of the hardware needed
- STL files to 3D print the case
- The software I used for the web app, and the Flutter app
Or even better - come find us at the upcoming conferences we are sponsoring. Make sure to follow us on X/Twitter or LinkedIn to hear where we’ll be.
The winners
So who won a hoodie? Our winners were Andrew Kolodiazhnyi and Ben Chatelain. Andrew and Ben - we’re looking forward to seeing your pics sporting your fine new hoodies!