Created
May 22, 2018 19:31
-
-
Save tvandergeer/33306e7bb6f76eb585a4b2d79643f889 to your computer and use it in GitHub Desktop.
Blynk combined with WS2812 ringled controlled via zeRGBa RGB controls on V1 and V2. Reset button on V0
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
/************************************************************** | |
* Blynk is a platform with iOS and Android apps to control | |
* Arduino, Raspberry Pi and the likes over the Internet. | |
* You can easily build graphic interfaces for all your | |
* projects by simply dragging and dropping widgets. | |
* | |
* Downloads, docs, tutorials: http://www.blynk.cc | |
* Blynk community: http://community.blynk.cc | |
* Social networks: http://www.fb.com/blynkapp | |
* http://twitter.com/blynk_app | |
* | |
* Blynk library is licensed under MIT license | |
* This example code is in public domain. | |
* | |
************************************************************** | |
* This example runs directly on ESP8266 chip. | |
* | |
* You need to install this for ESP8266 development: | |
* https://github.com/esp8266/Arduino | |
* | |
* Please be sure to select the right ESP8266 module | |
* in the Tools -> Board menu! | |
* | |
* Change WiFi ssid, pass, and Blynk auth token to run :) | |
* | |
**************************************************************/ | |
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space | |
#include <ESP8266WiFi.h> | |
#include <BlynkSimpleEsp8266.h> | |
#include <Adafruit_NeoPixel.h> | |
#define PIXEL_PIN D2 // Digital IO pin connected to the NeoPixels. | |
#define PIXEL_COUNT 16 | |
// Parameter 1 = number of pixels in strip, neopixel stick has 8 | |
// Parameter 2 = pin number (most are valid) | |
// Parameter 3 = pixel type flags, add together as needed: | |
// NEO_RGB Pixels are wired for RGB bitstream | |
// NEO_GRB Pixels are wired for GRB bitstream, correct for neopixel stick | |
// NEO_KHZ400 400 KHz bitstream (e.g. FLORA pixels) | |
// NEO_KHZ800 800 KHz bitstream (e.g. High Density LED strip), correct for neopixel stick | |
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ800); | |
// You should get Auth Token in the Blynk App. | |
// Go to the Project Settings (nut icon). | |
char auth[] = "[your token here]"; | |
// Your WiFi credentials. | |
// Set password to "" for open networks. | |
char ssid[] = "[wifi ssid here]"; | |
char pass[] = "[wifi pass here]"; | |
int i; | |
//Reset | |
BLYNK_WRITE(V0) | |
{ | |
for(int p=0;p<PIXEL_COUNT;p++) | |
{ | |
strip.setPixelColor(p, strip.Color(0,0,0)); | |
} | |
strip.show(); | |
i=0; | |
} | |
BLYNK_WRITE(V1) | |
{ | |
// strip.Color takes RGB values, from 0,0,0 up to 255,255,255 | |
strip.setPixelColor(i, strip.Color(param[0].asInt(),param[1].asInt(),param[2].asInt())); | |
i++; | |
if(i>PIXEL_COUNT) i=0; | |
strip.show(); | |
// process received value | |
} | |
BLYNK_WRITE(V2) | |
{ | |
for(int i=0;i<PIXEL_COUNT;i++) | |
{ | |
// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255 | |
strip.setPixelColor(i, strip.Color(param[0].asInt(),param[1].asInt(),param[2].asInt())); | |
} | |
strip.show(); | |
} | |
void setup() | |
{ | |
strip.begin(); | |
strip.show(); // Initialize all pixels to 'off' | |
Serial.begin(9600); | |
Blynk.begin(auth, ssid, pass); | |
i=0; | |
} | |
void loop() | |
{ | |
Blynk.run(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment