Actions were previously called Triggers. Some images may show the old Triggers terminology.

So now that we are sending cap-touch and light data to Adafruit IO and reacting to servo and NeoPixel events from it let's link them up.

Adafruit IO has a really cool feature for adding some logic to your data collection: actions.  A action is a response to an event getting posted, I.e. a new piece of data being added (aka published) to a feed.  When data gets added to a feed, any associated triggers compare the new value against a constant or the current value of another feed.

If the condition is satisfied it can take one of several actions:

  • email you a message,
  • send a webhook message, or
  • publish a specific value to feed.

It's the last of these that is of particular interest.

Let's make the cap-touch move the servo between 0 and 180 degrees. Since we send a 1 and 0 when the cap-touch is touched and released, respectively, we can use that in two triggers. One for each state.

In the main Adafruit IO screen, on the left side, you'll see a menu item Actions. Click that and create the two Reactive Actions below. They look similar but have slightly different values.

We can do something similar with the light and NeoPixel feeds. In all we have four actions:

With these in place, load up the code below in remote_monitor.ino. This program has both the touch input code and the servo/NeoPixel output code.

When the sketch is running, you should be able to touch and release the capacitive touch sensor 1 to control the servo, as well as vary the lighting on the photoresistor to control the color of the NeoPixels.

Multiple Data Sources

Things get interesting when you take into account that multiple devices can connect to Adafruit IO and publish to feeds. If we build another Feather + Crickit and put a input only version of the sketch on it (below) we can have it publish readings that the actions then use. The original Feather + Crickit consumes the output from the actions. Conceivably (possibly limited by the data limits on your Adafruit IO account) you could have any number of nodes feeding data to the system.

// SPDX-FileCopyrightText: 2018 Dave Astels for Adafruit Industries
// SPDX-License-Identifier: MIT

// Crickit + Adafruit IO Publish Example
// Adafruit invests time and resources providing this open source code.
// Please support Adafruit and open source hardware by purchasing
// products from Adafruit!
// Written by Dave Astels for Adafruit Industries
// Copyright (c) 2018 Adafruit Industries
// Licensed under the MIT license.
// All text above must be included in any redistribution.

#include "config.h"
#include <Adafruit_Crickit.h>


#define IO_LOOP_DELAY (1000)
unsigned long lastUpdate = 0;

// set up the feeds
AdafruitIO_Feed *light;
uint16_t last_reported_light = 0;

AdafruitIO_Feed *touch;
boolean last_touch = false;

// set up the Crickit

Adafruit_Crickit crickit;

void setup_feeds()
  light = io.feed("crickit.light");
  touch = io.feed("crickit.touch-0");

void setup()
  Serial.println("Feeds set up");

  // start the serial connection

  // wait for serial monitor to open
  while(! Serial);

  Serial.println("Connecting to Adafruit IO");

  // connect to

  // wait for a connection
  while(io.status() < AIO_CONNECTED) {
    //    Serial.println(io.statusText());

  // we are connected

  if (!crickit.begin()) {
    Serial.println("Error starting Crickit!");
  } else {
    Serial.println("Crickit started");

  Serial.println("setup complete");

void loop()

  //; is required for all sketches.
  // it should always be present at the top of your loop
  // function. it keeps the client connected to
  //, and processes any incoming data.;

  if (millis() > (lastUpdate + IO_LOOP_DELAY)) {

    uint16_t light_level = crickit.analogRead(CRICKIT_SIGNAL1);
    uint16_t light_delta = abs(light_level - last_reported_light);

    if (light_delta > 10) {
      last_reported_light = light_level;
      Serial.print("Sending ");
    Serial.print("Light: ");

    uint16_t val = crickit.touchRead(0);

    if (val >= CAPTOUCH_THRESH && !last_touch) {
      last_touch = true;
      Serial.println("CT 0 touched.");
    } else if (val < CAPTOUCH_THRESH && last_touch) {
      last_touch = false;
      Serial.println("CT 0 released.");

    // after publishing, store the current time
    lastUpdate = millis();


This guide was first published on Jul 18, 2018. It was last updated on Jul 18, 2018.

This page (Setting up Actions) was last updated on Jul 12, 2018.

Text editor powered by tinymce.