The AdafruitIO connection already works with my NodeMCU, but I don't know how to make it light up. When I press the button in the AdafruitIO Dashboard I receive a message on my Serial monitor saying "HIGH". And the same goes for turning it off. I just don't know to connect both together. Can somebody help me?
// Adafruit IO Digital Output Example
// Tutorial Link: Overview | Adafruit IO Basics: Digital Output | Adafruit Learning System
//
// Adafruit invests time and resources providing this open source code.
// Please support Adafruit and open source hardware by purchasing
// products from Adafruit!
//
// Written by Todd Treece for Adafruit Industries
// Copyright (c) 2016 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"
#include <FastLED.h>
/************************ Example Starts Here *******************************/
// digital pin 5
#define LED_PIN 5
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
#define NUM_LEDS 60
CRGB leds[NUM_LEDS];
#define BRIGHTNESS 100
#define FRAMES_PER_SECOND 90
uint8_t gHue = 0;
// set up the 'digital' feed
AdafruitIO_Feed *digital = io.feed("digital");
void setup() {
pinMode(LED_PIN, OUTPUT);
//FastLED.addLeds<LED_TYPE,LED_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
//FastLED.setBrightness(BRIGHTNESS);
// start the serial connection
Serial.begin(115200);
// wait for serial monitor to open
while(! Serial);
// connect to io.adafruit.com
Serial.print("Connecting to Adafruit IO");
io.connect();
// 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.
digital->onMessage(handleMessage);
// wait for a connection
while(io.status() < AIO_CONNECTED) {
Serial.print(".");
delay(500);
}
// we are connected
Serial.println();
Serial.println(io.statusText());
digital->get();
}
void loop() {
// io.run(); is required for all sketches.
// it should always be present at the top of your loop
// function. it keeps the client connected to
// io.adafruit.com, and processes any incoming data.
io.run();
//rainbow(LED_PIN);
//FastLED.show();
//FastLED.delay(1000/FRAMES_PER_SECOND);
//EVERY_N_MILLISECONDS( 20 ) { gHue++; }
//Serial.readString();
/if(LED_PIN == HIGH) {/
fill_rainbow(leds, NUM_LEDS, gHue, 7);
FastLED.show();
FastLED.delay(1000/FRAMES_PER_SECOND);
EVERY_N_MILLISECONDS( 20 ) { gHue++; }
//}
if(LED_PIN == LOW) {
fill_solid(leds, NUM_LEDS, CRGB(0, 0, 0));
FastLED.clear();
}
}
// 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 <- ");
if(data->toPinLevel() == HIGH)
Serial.println("HIGH");
else
Serial.println("LOW");
digitalWrite(LED_PIN, data->toPinLevel());
}
void rainbow() {
fill_rainbow( leds, NUM_LEDS, gHue, 7);
}