Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save huhn511/6acfb1e0d151b72b5228a4ea63d16e09 to your computer and use it in GitHub Desktop.
Save huhn511/6acfb1e0d151b72b5228a4ea63d16e09 to your computer and use it in GitHub Desktop.
ESP8622 connect to wlan with light feedback
#include <Adafruit_NeoPixel.h>
#define PIN 5
int numPixels = 12;
#include <ESP8266WiFi.h>
const char* ssid="<YOUR WLAN SSID";
const char* password="<YOUR WLAN PASSWORD>";
Adafruit_NeoPixel strip = Adafruit_NeoPixel(numPixels, PIN, NEO_GRB + NEO_KHZ800);
uint32_t blue = strip.Color(0, 0, 255);
uint32_t green = strip.Color(0, 255, 0);
int counter = 0;
void setup() {
strip.begin();
strip.setBrightness(15);
strip.show();
Serial.begin(115200);
Serial.println();
Serial.print("Wifi connection to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
Serial.println();
Serial.print("Connecting");
while(WiFi.status() != WL_CONNECTED ) {
strip.clear(); // Set all pixel colors to 'off'
strip.setPixelColor(counter, blue);
strip.show();
delay(1000);
// increment counter
counter++;
// counter should only have values from 0-11
counter = counter % 12;
}
Serial.println("WiFi connected!");
Serial.print("ESP IP Address:");
Serial.println(WiFi.localIP());
// Set all leds to green
for(uint16_t i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, green);
strip.show();
}
}
void loop() { }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment