Skip to content

Instantly share code, notes, and snippets.

@makersenses
Created April 22, 2021 16:04
Show Gist options
  • Save makersenses/6ab934d4795e7c2bcf58ef9aaa68d4d2 to your computer and use it in GitHub Desktop.
Save makersenses/6ab934d4795e7c2bcf58ef9aaa68d4d2 to your computer and use it in GitHub Desktop.
wifi_esp32_control_NeoPixel
#include "Senses_wifi_esp32.h"
#include <Adafruit_NeoPixel.h>
int button_pin = 26;
int led_pin = 27;
int numPixels = 1;
int pixelFormat = NEO_GRB + NEO_KHZ800;
Adafruit_NeoPixel *pixels;
const char *ssid = "your-wifi-network-name";
const char *passw = "your-wifi-password";
const char *userid = "your-senses-user-id";
const char *key = "your-device-key";
String response = "";
int control_port = 1;
Senses_wifi_esp32 myiot;
void setup() {
Serial.begin(115200);
pixels = new Adafruit_NeoPixel(numPixels, led_pin, pixelFormat);
pixels->begin();
pinMode(button_pin, INPUT_PULLUP);
response = myiot.connect(ssid, passw, userid, key);
Serial.println(response);
}
void loop() {
response = myiot.getDigitalControl(control_port);
Serial.println(response);
if (response == "on")
{
pixels->setPixelColor(0, pixels->Color(255, 0, 0)); pixels->show(); delay(500);
}
else if (response == "off")
{
pixels->clear(); pixels->show();
}
delay(1000);
}
© 2021 GitHub, Inc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment