Practice Exercise: Ambient Calendar Alert

Table of contents

  1. Starting point
  2. Programming the Behavior
  3. Connectivity
  4. Going Further
The Ambient Orb. Credit: Ambient Devices

The Ambient Orb. Credit: Ambient Devices

This practice exercise will challenge you to create an ambient calendar alert using a neopixel strip. By the end of the project, you’ll have connected your Particle device to your Google Calendar through IFTTT. This will send an alert to your device a few minutes before an appointment. You’ll have programmed the neopixels to respond by fading up slowly and signalling there’s an event and changing color as the event approaches. Ultimately it will then fade out after the event has begun. To prepare this simple ambient notification system, you’ll get familiar with using millis() to sequence durational transitions and you’ll get familiar with for loops, using libraries and programming effects and behaviors using light.

Starting point

To begin this exercise exercise, start by

  • Create a circuit containing the neopixel lights.

  • Create code for your Particle that does the following:

    • Includes the necessary libraries e.g. the neopixel library
    • Contains a seires of variables for the pins you’re using.
    • Uses setup to configure the pins in use and initialize libraries
      • Programs the leds to fade up.

Doing this will allow you to test the components and make sure they are working correctly before going further.

Programming the Behavior

Ultimately, we’ll connect our device to IFTTT and get a notification 15 minutes before the event should start. We’ll program a behavior where it will fade up slowly for 5 minutes, slowly transition colors as we approach the start of the meeting. After 10 minutes, it will be a solid red. For 5 minutes after the event, it will fade out slowly.

Workflow diagram for the practice exercise

Workflow diagram for the practice exercise

On startup (in `setup):

  • Fade up all of the LEDS i.e. progressively turn on all of the LEDs, one by one. This will let you quickly test that everythings behaving as you’d expect when you plug in the device!
  • Optional: Blink the LEDs 3 times and then turn them off to indicate startup is complete.

To remotely control the ambient notification

  • Add two Particle cloud function(s). One to start the ambient notification and one to stop the notification
  • This should update a variable that indicates if the device should display the ambient notification.

In the loop()

  • Check if the ambient notification should display.
  • If it’s displaying, the notification should unfold over 20 minutes as follows:
    • First 5 minutes: It should begin by slowly fading up and displaying a single color (blue or green)
    • Middle 10 minutes: It should slowly transition to red over the course of the next 10 minutes.
    • 5 minutes after the event: It should slowly fade out to off.

You should also add cloud variables that allow you to see if the timer is running, and the amount of time elapsed in the sequence. This will make it easier to debug and understand what’s happening when your program runs.

Hint: Define the times for each phase of the interaction as global variables. When you’re testing, reduce/divide these times by 10 to make it much quicker to see how your device is behaving. When it’s close to implemented you can then change the times to longer durations. For example

//int COMPLETE_AFTER = 20 * 60 * 1000; // 20 minutes from start to fade out
int COMPLETE_AFTER = 2 * 60 * 1000; // FOR TESTING: 2 minutes from start to finish


When programming a device that has a networked interaction, always leave this component to last. You can test the behavior by calling the Particle.function from the online console.

Only when you’re sure the device is behaving how you want should you connect it and test it with live data. So, the final step should be to use IFTTT and connect it to your calendar.

To connect your calendar to your Particle using IFTTT:

  • Create a new applet on IFTTT
  • Choose the Google Calendar Service as your trigger. Select the Any Event Starts option. Select the calendar you want to use and choose 15 minutes as the Time before an event starts.
  • Choose the Particle service as the action. Select the option to Call a function and choose the function you’ve defined on your Particle device.

Going Further

Once you’ve achieved the outcome, you can try some of the below and experiment to improve your coding skills

Exercise 1

Add a Particle.function to customize the time / duration of the countdown

Exercise 2

Wire up a pushbutton and allow the pushbutton to dismiss the alert if pressed for 3 seconds.

Table of contents