Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ESP-8266
- //Led Strip WS2812(B)
- /*
- RED -> V0 Send on release (ON) 0 -> 255
- GREEN -> V1 Send on release (ON) 0 -> 255
- BLUE -> V2 Send on release (ON) 0 -> 255
- BRIGHTNESS -> V3 Send on release (ON) 0 -> 255
- */
- #include <BlynkSimpleEsp8266.h>
- #include <ESP8266WiFi.h>
- #include <Adafruit_NeoPixel.h>
- #define LEDS 64
- #define STRIP_PIN 2
- char auth[] = "Codice";
- char ssid[] = "Uaifai";
- char pass[] = "Password";
- Adafruit_NeoPixel pixels = Adafruit_NeoPixel(LEDS, STRIP_PIN, NEO_GRB + NEO_KHZ800); //N° Leds e N° pin
- volatile uint8_t red = 0, green = 0, blue = 0, brightness = 0;
- void showUpdates() {
- //Show updates of all leds
- pixels.clear();
- for (uint16_t px = 0; px < LEDS; ++px) {
- pixels.setPixelColor(px, red, blue, green, brightness);
- }
- pixels.show();
- }
- BLYNK_WRITE(V0) {
- //RED
- red = param.asInt();
- showUpdates();
- }
- BLYNK_WRITE(V1) {
- //GREEN
- green = param.asInt();
- showUpdates();
- }
- BLYNK_WRITE(V2) {
- //BLUE
- blue = param.asInt();
- showUpdates();
- }
- BLYNK_WRITE(V3) {
- //BRIGHTNESS
- brightness = param.asInt();
- showUpdates();
- }
- void setup() {
- pixels.begin(); //INIT strip
- pixels.clear(); //All leds 'off'
- Blynk.begin(auth, ssid, pass);
- }
- void loop() {
- Blynk.run();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement