Created
June 25, 2017 23:27
-
-
Save anonymous/105b6fb6225499555061332060906c61 to your computer and use it in GitHub Desktop.
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 <ESP8266WiFi.h> | |
#include <BlynkSimpleEsp8266.h> | |
#include "FastLED.h" | |
//---FastLED definitions and CRGB--- | |
#define LED_PIN 3 // GPIO pin for RGB LEDs. | |
#define NUM_LEDS 44 // Number of LEDs connected. | |
#define BRIGHTNESS 64 // Default LED brightness. | |
#define LED_TYPE WS2812B | |
#define COLOR_ORDER GRB | |
CRGB leds[NUM_LEDS]; | |
//---variables for our RGB values--- | |
int r = 500; | |
int g = 500; | |
int b = 500; | |
//---variables for On/Off, and Auto/Manual toggle | |
int masterSwitch = 1; | |
int autoMode = 1; | |
//--- int/byte for automatic hue incrementation--- | |
uint8_t gHue = 0; // rotating "base color" used by many of the patterns | |
//---Blynk auth code and wifi details--- | |
char auth[] = "YourAuthCode";//Blynk authorisation | |
char ssid[] = "YourWifiName"; | |
char pass[] = "YourWifiPassword"; | |
void setup() | |
{ | |
// power-up safety delay | |
delay( 3000 ); | |
Serial.begin(9600); | |
//--- add the LEDS to FastLED and set the brightness--- | |
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalSMD5050 ); | |
FastLED.setBrightness( BRIGHTNESS ); | |
#define FRAMES_PER_SECOND 120 | |
//---start communication with the Blynk server --- | |
Blynk.begin(auth, ssid, pass); | |
} | |
void loop() | |
{ | |
Blynk.run(); | |
if(masterSwitch==0) | |
{ | |
for (int i=0;i<NUM_LEDS; i++) | |
{ | |
leds[i] = CRGB::Black; | |
FastLED.show(); | |
delay(30); | |
} | |
} | |
if(autoMode==0 && masterSwitch ==1) | |
{ | |
for (int i=0;i<NUM_LEDS; i++) | |
{ | |
leds[i] = CRGB(r, g, b); | |
FastLED.show(); | |
delay(30); | |
} | |
} | |
if(autoMode==1 && masterSwitch ==1) | |
{ | |
fill_rainbow( leds, NUM_LEDS, gHue, 7); | |
// send the 'leds' array out to the actual LED strip | |
FastLED.show(); | |
// insert a delay to keep the framerate modest | |
FastLED.delay(1000/FRAMES_PER_SECOND); | |
EVERY_N_MILLISECONDS( 20 ) { gHue++; } // slowly cycle the "base color" through the rainbow | |
} | |
} | |
//---Master On/Off--- | |
BLYNK_WRITE(V0) | |
{ | |
masterSwitch = param.asInt(); | |
} | |
//--- Red slider value--- | |
BLYNK_WRITE(V1) | |
{ | |
r = param.asInt(); | |
} | |
//--- Green slider value--- | |
BLYNK_WRITE(V2) | |
{ | |
g = param.asInt(); | |
} | |
//--- Blue slider value--- | |
BLYNK_WRITE(V3) | |
{ | |
b = param.asInt(); | |
} | |
BLYNK_WRITE(V4) | |
{ | |
autoMode = param.asInt(); | |
} | |
BLYNK_WRITE(V5) | |
{ | |
int g = param.asInt(); | |
if(g==1) | |
{ | |
for(int a = 0; a < 10 ; a++) | |
{ | |
for (int i=0;i<NUM_LEDS; i++) | |
{ | |
leds[i] = CRGB(1023, 0, 0); | |
FastLED.show(); | |
delay(10); | |
FastLED.clear(); | |
delay(10); | |
} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment