This project was designed to visualize changes in data for my school's Physical Computing class. The project had to follow the theme of "Cultivating Light." My teachers allowed me to interpret the theme in anyway I wanted, so I took a more literal approach. I wanted to represent CultivatingLight as the physical brightness of the world, and how more "life" is present when it's lighter outside (i.e. in the summer.
The idea for the sculpture was a tree that had "fruits" sticking out of it (represented by lights) that would change color and brightness based on the weather in Chicago. Additionally, there was a rainbow that I added on the side that would spin in the "sky" of my box. Nearing the end of the project, I had added extra details like animals and a mini bonfire.
Using the OpenWeather APIFor the data used in my project, I used the OpenWeather API that pulled data from a weather station a few miles South of Downtown Chicago. In order to pull data, I created a webhook integration in the Particle IDE that would pull data using my API endpoint. In order to get my API endpoint, I went to openweathermaps.org and signed up for an API key.
Once I had my API endpoint I went to Particle's IDE and created a GET webhook.
My API endpoint returned a JSON object containing a lot of values I didn't need to use.
To fix this problem, I used a custom response template to pull only the data that I needed from the JSON in an easily usable format. This template was
{"w":"{{weather.0.main}}", "t":{{main.feels_like}}, "ws":{{wind.speed}}}
and it pulled only the weather, which returned the type of weather (ex: "Cloudy", "Clear, " "Rainy, etc.), the "feels like" temperature, and the wind speed.
In my project, my webhook runs every 10 seconds. This means that every 10 seconds, my Particle Photon publishes my getWeatherInfo webhook and retrieves JSON from my API endpoint. I created an extractInfo function so that everytime my webhook ran, it would utilize the JSON that the API returned.
The Stepper MotorFor my project, I used a 28BYJ-48 Stepper Motor with a ULN2003 driver board.
Set-up
To set up my motor, I connected the IN1, IN2, IN3, and IN4 pins on my driver board to the D1, D3, D4, D5 pins, respectively, on my Photon. I didn't use D2 because my LEDs were being addressed by my D2 pin.
Here are the global variables I used to set up my motor.
Because the motor speed depends on the wind speed that is pulled from my API endpoint, I set the speed of my motor inside of my extractInfo function, so that every time my webhook runs, it updates the speed of the motor to match the wind speed.
To do this, I created a handler function for the wind speed that converted the JSON data into a speed value for my motor by constraining the wind speed value and mapping it to a speed value.
And then in my extractInfo function, I added this line.
The LEDs that I used in this project were AdaFruit's NeoPixel Diffused 5mm Through-Hole LEDs. A total of 5 LEDs were used to represent the "fruit" in my tree.
Set-up
Each LED was addressed by the same pin on my photon, D2, and were connected via Female/Male jumper wires. Each Through-Hole LED had 4 pins, from left to right they are Data In, Power, Ground, and Data Out. For each LED, I connected the Power pin to the positive terminals on my protoboard and the Ground pin to the negative terminals on my protoboard via Male/Male jumper wires. The data pins are how AdaFruit allows for all of the LEDs to be addressable by the same pin. For the Data In and Out pins, I first connected a Male/Male jumper wire between the D2 pin on my Photon and the Data In pin on my leftmost LED. Then, I connected a Male/Male jumper wire between the Data Out pin of the same LED to the Data In pin to the LED next to it on the right. I continued this for all of my LEDs until they were all connected to each other.
Here are the global variables I used to set up my lights.
One thing to note, many of these variables are unrelated to the set-up of the lights themselves (head, pulse phase, precipLastMove, precipInterval, and flip). Instead, they were used later on in my program to code the actual pattern of the lights (which I will get to later). Similarly to my motor, the brightness of the lights is determined by the "feels like" temperature from my JSON. Thus, I set the brightness of my lights inside of the extractInfo as well, so that every time my webhook runs the brightness of the lights is updated.
To do this, I created a handler function for the temperature that converted the JSON data into a brightness value for my lights by constraining the temperature value and mapping it to a brightness value.
And then in my extractInfo function, I added this line.
For the moving rainbow in my project, I created a small rod that could mount onto the tip of my stepper motor, such that it could rotate freely. I made the model using Tinkercad.
My project has 3 different visual representations. One for clear/sunny weather, one for cloudy weather, and one for any precipitation.
Sunny
My first pattern was the pattern for clear/sunny weather. For this pattern, I created a fast moving light that bounced from LED to LED, creating a sort of glowing trail through my LEDs. For each frame, my code lighted up 4 LEDs (centered on my head variable). The key idea was that each LED further behind the "head" LED (t = 0, 1, 2, 3 ) gets dimmer in increments of 25%.
After lighting an LED, the head variable increments by one pixel each call, so that the trail loops continuously.
This creates a bright leading LED that fades to near-black as the next LEDs light up. The color is a warm orange/amber to represent the glow of the sun.
Cloudy
For my second pattern, I created one that would match with cloudy weather. For this pattern, I created a slow, breathing LED that dimmed and brightened. My code for this pattern used a sine wave (with a phase of pulsePhase) to smoothly oscillate the gray color of my LED between 20 and 170. Because R, G, and B must all be the same for the gray color to appear, the result is a white/gray light that slowly pulses.
Precipitation
My third and last pattern was to represent precipitation. For this pattern, I simulated falling precipitation by creating two alternating groups that flickered back and forth. Even-indexed LEDs and odd-indexed LEDs swap between a bright and base color every tick. My precipInterval variable controls how fast they alternate.
Additionally, the color of my lights shifted based on the type of precipitation. When weather type was "Rain, " the lights were a deep blue. When weather type was "Drizzle, " the lights were a slightly softer blue. When it was "Thunderstorm, " the lights shifted to yellowy purple tones that represented lightning and thunder. When it was "Snow, " the lights became near-white with a blue tint.
Before integrating the electronics with the sculpture, I first had to transfer the components on my breadboard onto a protoboard via soldering. After I finished soldering all of my components onto the protoboard, I began working on the sculpture. I used brown air dry clay to form a hollow trunk around my lights. After finishing the trunk, I placed a bunch of synthetic moss around the lights to create the foliage of the tree. I poked the LEDs through the moss in order to create the "fruits" that I had mentioned earlier.
After completing the tree, I added the grass floor, animals, and the bonfire for scenery. Additionally, I painted paper and glued it onto my 3D printed rod in order to create the rainbow, and attached it to the side of the box so it could freely rotate.





















_3u05Tpwasz.png?auto=compress%2Cformat&w=40&h=40&fit=fillmax&bg=fff&dpr=2)
Comments