Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Adafruit_DotStar.h>
- #include <SPI.h>
- #include <ESP8266WiFi.h>
- #include <BlynkSimpleEsp8266.h>
- #define NUMPIXELS 60
- #define DATAPIN 15 // GPIO15 - MISO
- #define CLOCKPIN 14 // GPIO14 - CLK
- Adafruit_DotStar strip = Adafruit_DotStar(NUMPIXELS, DATAPIN, CLOCKPIN);
- char auth[] = "629c4b81452040xxxxxxxxxxxxxxxxxx";
- void setup() {
- Blynk.begin(auth, "YOUR SSID", "YOUR PASS");
- strip.begin();
- strip.show();
- }
- int head = 0, tail = -10, color_r=255, color_g=0, color_b=0; //initially set to show red only
- uint32_t color = 0xFF0000;
- uint8_t count=0;
- BLYNK_WRITE(1) { //in blynk app, large RED slider set to virtual pin 1 with minimum = 0 and maximum = 255
- color_r = param.asInt();
- }
- BLYNK_WRITE(2) { //in blynk app, large GREEN slider set to virtual pin 2 with minimum = 0 and maximum = 255
- color_g = param.asInt();
- }
- BLYNK_WRITE(3) { //in blynk app, large BLUE slider set to virtual pin 3 with minimum = 0 and maximum = 255
- color_b = param.asInt();
- }
- uint32_t ticker=millis();
- void loop() {
- Blynk.run(); // Initiates Blynk
- strip.setPixelColor(head, color);
- strip.setPixelColor(tail, 0);
- strip.show();
- if (millis()-ticker>20) {//this substitutes for the 20 millisecond delay
- ticker= millis();
- // delay(20);
- color <<= 8; //shift 8 bits to the left to clear out previous value
- color |= color_r;
- color <<=8;
- color |= color_g;
- color <<=8;
- color |= color_b;
- if(++head >= NUMPIXELS) {
- count++;
- head = 0;
- //if((color >>= 8) == 0)
- }
- if(++tail >= NUMPIXELS) tail = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement