Recently I bought ws2812b LED strip and decided to make something cool with Blynk, NodeMCU and LEDs. The first idea was to change LEDs color with Blynk app. After one hour of reading I created a simple sketch which didn’t work out for me. Maybe someone can tell me what I’m doing wrong?
#include <Adafruit_NeoPixel.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#define PIN 5
Adafruit_NeoPixel strip = Adafruit_NeoPixel(300, PIN, NEO_GRB + NEO_KHZ800);
int alarmPinTop = 4;
int alarmPinBottom = 14;
int alarmValueTop = LOW;
int alarmValueBottom = LOW;
int R; // red
int G; // green
int B; // blue
int Brightness;
//===========================//
//===*---*===Blynk===*---*===//
//===========================//
char auth[] = "f3***********************";
char ssid[] = "HUAWEI-*******";
char pass[] = "*************";
BLYNK_WRITE(V1) // zeRGBa assigned to V1
{
R = param[0].asInt();
G = param[1].asInt();
B = param[2].asInt();
}
BLYNK_WRITE(V2)
{
int Brightness; = param.asInt();
}
void setup() {
strip.begin();
strip.setBrightness(Brightness);
strip.show();
Serial.begin (9600);
pinMode(alarmPinTop, INPUT_PULLUP);
pinMode(alarmPinBottom, INPUT_PULLUP);
pinMode(5, OUTPUT);
Blynk.begin(auth, ssid, pass);
delay(2000);
}
void loop() {
Blynk.run();
if (alarmPinBottom == LOW && alarmPinTop == LOW) {
strip.setPixelColor(0, R, G, B);
strip.setPixelColor(29, R, G, B);
strip.setPixelColor(30, R, G, B);
strip.setPixelColor(59, R, G, B);
strip.setPixelColor(60, R, G, B);
strip.setPixelColor(89, R, G, B);
strip.setPixelColor(90, R, G, B);
strip.setPixelColor(119, R, G, B);
strip.setPixelColor(120, R, G, B);
strip.setPixelColor(149, R, G, B);
strip.setPixelColor(150, R, G, B);
strip.setPixelColor(179, R, G, B);
strip.setPixelColor(180, R, G, B);
strip.setPixelColor(209, R, G, B);
strip.setPixelColor(210, R, G, B);
strip.setPixelColor(239, R, G, B);
strip.setPixelColor(240, R, G, B);
strip.setPixelColor(269, R, G, B);
strip.setPixelColor(270, R, G, B);
strip.setPixelColor(299, R, G, B);
strip.show();
}
}