Articulated Stained Glass Butterfly
Articulated Stained Glass Butterfly
For our Robotics Midterm, we were tasked with making a very complex thermometer. For this assignment, we had to utilize opencv image processing, airtable, and connecting with adafruit via MQTT with our computers and our Raspberry Pi picos.
It is safe to say that this midterm covered a lot of topics! I was also able to integrate in stained glass which I had just learned and was really excited to apply.
Most code in this project was written with the help of ChatGPT.
Butterfly wings with copper foil tape on them before soldering
OpenCV image and code output
My approach to image processing was to crop the image down to the center of the image and then only show the green values. I then count the amount of pixels that are over 50 (green) and the amount that are under 50 (red). Whichever is higher is the color that is outputted. This value is then sent to airtable using the airtable API using the send-color-to-airtable code I wrote.
The accelerometer and the thermistor both make the wings flap. When the accelerometer is moved the wings flap slow and when the thermistor is touched/heated up the wings move fast. The wings are on a pulley system using a servo in the box. The servo pulls the string in and out. The wings are epoxied to hinges which allows them to flap when pulled.
Overhead view of the pulley system.
This device utilizes a thermistor, an accelerometer, a servo, and 2 stained glass butterfly wings on hinges. The wings took about 7 hours to make in total. The thermistor was calibrated by measuring the resistance at freezing, boiling, and room temperature. The resistances were then used to calculate the Steinhart constants.
The Raspberry Pico attached to the accelerometer.
Onshape rendering of the casing.
This was the most challenging aspect of the assignment for me. In many of my previous projects for this class, my partners handled the coding while I did the construction and fabrication side of things. This project revealed a lot of weaknesses that I had in this class. I am particularly proud that I was able to figure out all of the MQTT to Adafruit stuff and that I was able to integrate all aspects of the assignment into one code for the Raspberry Pi Pico. I feel a lot more confident in my ability to handle tasks like this in the future after completing this assignment.
All of the code for this assignment is in my GitHub repository (yay! I know how to use Github now!)
The way the code below works is that it is an while True loop that runs through each aspect of the code with a 1-second sleep at the end of the loop. This is definitely a pretty simple way of doing this but it works really well for the purposes of this project. I also learned how to use flagging variables to stop the wing flap functions from running multiple times in a row which had been an issue.
Accelerometer and thermister activating the wings:
OpenCV Working: