Created
April 29, 2020 07:01
-
-
Save suadanwar/385e69035fd980cc45c3742bdcf33a1b to your computer and use it in GitHub Desktop.
This sample code is use to control the LED strip using Blynk App and ESP32.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define BLYNK_PRINT Serial | |
#include <WiFi.h> | |
#include <WiFiClient.h> | |
#include <BlynkSimpleEsp32.h> | |
#include <Adafruit_NeoPixel.h> | |
#include <SPI.h> | |
#define PIN 27 | |
#define NUMPIXELS 30 | |
#define BLYNK_PRINT Serial | |
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[] = "YourAuthToken"; | |
// Your WiFi credentials. | |
// Set password to "" for open networks. | |
char ssid[] = "YourNetworkName"; | |
char pass[] = "YourPassword"; | |
BLYNK_WRITE(V2) | |
{ | |
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.setPixelColor(i, pixels.Color(R, G, B)); | |
pixels.show(); | |
} | |
} | |
void setup() | |
{ | |
// Debug console | |
Serial.begin(9600); | |
Blynk.begin(auth, ssid, pass); | |
pixels.begin(); | |
} | |
void loop() | |
{ | |
Blynk.run(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment