I'm looking to control some LED strip lighting from my Android via Blynk.
I'm comfortable flashing the ESP with the code below.
My question is regarding the hardware and wiring. Is GPIO2 the best choice for the LED data line? Do I need to put a resistor or cap anywhere? Can I just run GPIO2 strait in to my LED strip?
I realise I'll need a logic level converter from the ESP (3.3v) GPIO2 pin to the DIN on the WS2812 (5v) - This is not in the diagram.
Hardware set up:
Thanks!
#include <Adafruit_NeoPixel.h>
#include <SPI.h>
#include <BlynkSimpleEsp8266.h>
#include <ESP8266WiFi.h>
#define PIN 4 // GPIO pin <-- Pin 4 is actually the broken out pin marked GPIO2
#define NUMPIXELS 144 // Number of pixels in strip
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = “BLYNKAUTHCODE”;
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, “SSID”, “PASSWORD”);
pixels.begin();
}
BLYNK_WRITE(V1) // Widget WRITEs to Virtual Pin V1
{
int R = param[0].asInt();
int G = param[1].asInt();
int B = param[2].asInt();
Serial.println(R);
Serial.println(G);
Serial.println(B);
for(int i=0;i<NUMPIXELS;i++){
// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
pixels.setPixelColor(i, pixels.Color(R,G,B)); // Moderately bright green color.
pixels.show(); // This sends the updated pixel color to the hardware.
}
}
void loop()
{
Blynk.run();
}
edit: changed diagram and pin number in code.