Intention
In this lab we will learn to use neopixels to achieve ambient design and IFTTT to trigger the design by certain information.
The tricky part of this exercise is to build a reverse for loop to turn off each pixel one by one.
The initial condition of the reverse loop should be uint16_t i=strip.numPixels()-1, since the maximum number of the pixel should be 15 given the fact that the numbers list from 0 to 15 in the neopixel library.
I only use one function to achieve both loops by adding an indicator showing if the loop inside the function is in ascending or descending order.
Actually, I left one pixel out since if I terminate the reverse loop at i>=o instead of i>0, all the pixels turn off but the loop also terminates. Thus I have to leave one pixel out and directly start the next loop.
The video is attached.
I use colorAll function to turn on all the pixels at a certain color simultaneously. The key difference between colorAll and colorWipe is the positioning of strip.show() function - if it is inside the loop, it is lighting up the neopixel one by one; if it is outside the loop, it is turning all the neopixel on/off simualtaneously.
The video is attached.
I wrote a function call colorSingle to achieve this feature. Note that I change the data type wait to achieve larger wait time as the original wait time is only 8 digits (256 millis). In the for loop we only need to add an extra line to turn off the same pixel.
The video is attached.
I wrote only one Particle.function instead of three by parsing the command input. The format of input should be r,g,b that each of the letters represents the Red, Green, and Blue components. The remaining of the Particle.function calls colorAll function to light the pixels.
The video is attached.
The final practice exercise needs to combine neopixel with IFTTT. My IFTTT set up is as follows:
When any google calendar is 15 minutes away, call the Particle.function with the input of time duration of the alert. For simplicity of the demonstration, the time duration of each phase is set as only 1 minute.
The three phases of the alerts are inline with the advanced requirement on the course website:
The video below shows the process of the alert: how the alert is triggered by a google calendar event; the pixels fade up from dim white to solid white (increasing RGB values simultaneously in 1 minute); then fade the pixels from solid white to solid red (decreasing green and blue values from 255 to 0 in 1 minute); then fade out the pixels to dark (decreasing red value from 255 to 0 in 1 minute)
You can upload files of up to 20MB using this form.