This guide has been updated to use the Adafruit IO Arduino Library

The previous version of this guide used the Adafruit MQTT Arduino Library, but we suggest using the Adafruit IO Arduino Library. If you'd like to use this library, we suggest following the MQTT, Adafruit IO & You! Learn Guide

The Arduino sketch for the LEDs is also fairly straight forward. Copy the following code into a new Arduino sketch. You'll need to modify your config.h file to reflect your Wireless Network and Adafruit IO configuration.

If you do not know how to do this, follow the steps on the the Arduino Setup page. 

// Remote Control with the Huzzah + Adafruit IO
// LED Board
// Adafruit invests time and resources providing this open source code.
// Please support Adafruit and open source hardware by purchasing
// products from Adafruit!
// Written by Richard Albritton, based on original code by Tony DiCola for Adafruit Industries
// Licensed under the MIT license.
// All text above must be included in any redistribution.

/************************** Configuration ***********************************/

// edit the config.h tab and enter your Adafruit IO credentials
// and any additional configuration needed for WiFi, cellular,
// or ethernet clients.
#include "config.h"

/************************ Example Starts Here *******************************/

#include <ESP8266WiFi.h>

// RGB LED Pins
#define Blue  5
#define Green 4
#define Red   2

// set up the 'digital' feed
AdafruitIO_Feed *AssistiveCallButtons = io.feed("assistive-call-buttons");

void setup() {

  // set power switch tail pin as an output
  pinMode(Blue, OUTPUT);
  pinMode(Green, OUTPUT);
  pinMode(Red, OUTPUT);

  digitalWrite(Red, HIGH);
  digitalWrite(Blue, HIGH);
  digitalWrite(Green, HIGH);

  // set up serial monitor

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

  // connect to
  Serial.print("Connecting to Adafruit IO");

  // set up a message handler for the 'digital' feed.
  // the handleMessage function (defined below)
  // will be called whenever a message is
  // received from adafruit io.
  AssistiveCallButtons -> onMessage(handleMessage);

  // wait for a connection
  while(io.status() < AIO_CONNECTED) {

  // we are connected
  // recv. the assistive-call-buttons feed


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.;


// this function is called whenever an 'digital' feed message
// is received from Adafruit IO. it was attached to
// the 'digital' feed in the setup() function above.
void handleMessage(AdafruitIO_Data *data) {

  Serial.print("received <- AssistiveCallButtons");  
  switch(data->toInt()) {
    case 0: // your hand is on the sensor
      digitalWrite(Red, HIGH);
      digitalWrite(Blue, HIGH);
      digitalWrite(Green, HIGH);
    case 1: // your hand is close to the sensor
      digitalWrite(Red, LOW);
      digitalWrite(Red, HIGH);
      digitalWrite(Red, HIGH);
    case 2: // your hand is a few inches from the sensor
      digitalWrite(Red, HIGH);
      digitalWrite(Red, HIGH);
      digitalWrite(Red, LOW);
    case 3: // your hand is nowhere near the sensor
      digitalWrite(Red, HIGH);
      digitalWrite(Red, LOW);
      digitalWrite(Red, HIGH);
  // delay in-between reads for stability

You will then need to check that the name of your feed matches the feed defined in the sketch:

AdafruitIO_Feed *AssistiveCallButtons = io.feed("assistive-call-buttons");

When you are finished reviewing the sketch and have finished making the necessary config changes, upload the sketch to your HUZZAH using the Arduino IDE. You should also open up your Adafruit IO dashboard so you can monitor the Remote Buttons gauge.

Let's test this thing out now.

This guide was first published on Oct 11, 2015. It was last updated on Mar 08, 2024.

This page (LED Code) was last updated on Mar 08, 2024.

Text editor powered by tinymce.