Background:
This was a joint project between the physical computing and sculpture classes at my school. I was from the physical computing class and my partner was randomly chosen from the sculpture class. At the beginning of this project we were given the theme, "Cultivating Light."
Selectingourdatasource:
Originally we wanted to use an API that would return every time someone was born or every time someone was cured of brain cancer. Unfortunately these data sets either do not exist, are not publicly available or are not updated frequently. Most of these issues were due to medical privacy laws. We ended up settling on an air quality index (AQI) API (waqi.info). This API is free and it's also updated quite frequently (about every 1 - 2 hours). AQI is relevant to the project theme and our design since good air quality "allows for the cultivation of bright ideas."
Pullingdata:
With this API we could choose any AQI sensor on the globe but we ended up choosing a sensor that is closest to our school. This API returned a JSON response so I used a webhook and Particle's mustache templates in order to pull out the AQI value. In my code I decided to use four different AQI ranges: 0-50, 51-100, 101-150 and finally 150+. Based on the range that the AQI value falls into the color of the neopixel strip. The corresponding colors to the ranges are blue, green, yellow and red.
Selectingtheparts:
In my original plan for this project there was no DC motor. I was going to only use the stepper motor since it was a required part of the project. As time went on, I realized that this tiny motor wouldn't be strong enough to rotate the entire sculpture. I decided to use a 3-6 volt DC motor since my teacher already had one and I thought that it was going to be strong enough. However I was still required to use the stepper motor in my project, so I made a tiny "meter" that would point to the AQI range.
Another requirement of the project was that there had to be some sort of lights. I decided to use a neopixel strip since I have used one before and they are easy to work with. We used this strip in order to "simulate" neuron activation in the brain.
Writingthecode:
Writing the code was mostly straight forward. I used the Stepper library to control my stepper motor and the neopixel library to control the light strip. I also used PWM to control the speed of my DC motor.
In order to check whether there was a change in my data I used the Particle.publish() function to call my webhook and see whether there was a change in the AQI value being returned.
One thing that took a little bit to figure out was how to keep track of the position of the stepper motor. If the Photon 2 lost power in any way it would lose track of the position of the stepper motor. After some digging I found that I can save the position of the stepper motor to the Photon's EEPROM. Every time the Photon boots up, I am able to pull a value out of an EEPROM address and store it in a variable. Every time the stepper motor would move (when AQI changes) I would be able to store the new position at the same EEPROM address. The way that I am tracking position is by subtracting the current position from the target position and multiplying the result by the amount of steps it takes to get to the next "level."
Thefinalproduct:
IssuesandwhatIwouldchange:
The head is lopsided because mounting mechanism for the DC motor completely broke right before the deadline. If I were to do this project again I would definitely rethink our mounting mechanism and how we would combine the sculpture portion and the computer portion of the project.







Comments