Back to Parent

Outcome


Intention

In this lab we will learn to use neopixels to achieve ambient design and IFTTT to trigger the design by certain information.

Neopixel Exercise 1

Modify the code to light up pixel by pixel then reverse the sequence turning each pixel off one by one.

Approach

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.

Show Advanced Options
Show Advanced Options

Neopixel Exercise 2

Modify the code to light up blue, then red, then green then white in sequence.

Approach

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.

Show Advanced Options
Show Advanced Options

Neopixel Exercise 3

Change the code to only light up only one pixel at a time. With each loop move that pixel one position higher. When it reaches the final pixel, restart the sequence at zero i.e. build a single pixel that will continually cycle.

Approach

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.

Show Advanced Options
Show Advanced Options

Neopixel Exercise 4

Add three Particle.function to set the Red, Green and Blue components. Allow these values to be set from 0-255 and as they are set to change all of the pixels on the LED strip to that color.

Approach

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.

Show Advanced Options
Show Advanced Options

Practice Exercise: Ambient Calendar Alert

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:

  1. 15 minutes before the calendar event starts, the ambient alert will begin displaying.
  2. It will fade up slowly for 10 minutes to solid white
  3. 5 minutes before the meeting, the color will begin to slowly change from white to red over those 5 minutes.
  4. At the time when the meeting takes place, the ambient display will present as red
  5. Then it will slowly fade out over 5 more minutes.

Wx20201130 232538.thumb
Show Advanced Options
Show Advanced Options

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)

Show Advanced Options

Reflection

In this lab, I had a lot of fun playing with neopixels, and also got a chance to know IFTTT as a powerful IoT tool.

Drop files here or click to select

You can upload files of up to 20MB using this form.