forked from hansjny/Natural-Nerd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ikealamp.ino
59 lines (46 loc) · 956 Bytes
/
ikealamp.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <FastLED.h>
#define BLYNK_PRINT Serial
#define NUM_LEDS 26
char* token = "blynktoken";
char* ssid = "wifisdid";
char* pw = "wifipassword";
CRGB leds[NUM_LEDS];
CRGB color = CRGB(255, 255, 255);
void setup() {
Serial.begin(9600);
FastLED.addLeds<NEOPIXEL, 2>(leds, NUM_LEDS);
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB(255, 255, 255);
}
FastLED.show();
Blynk.begin(token, ssid, pw);
}
void updateColors() {
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = color;
}
FastLED.show();
}
BLYNK_WRITE(V0) {
color.r = param.asInt();
updateColors();
}
BLYNK_WRITE(V1) {
color.g = param.asInt();
updateColors();
}
BLYNK_WRITE(V2) {
color.b = param.asInt();
updateColors();
}
void Blynk_Delay(int milli){
int end_time = millis() + milli;
while(millis() < end_time){
Blynk.run();
}
}
void loop() {
Blynk.run();
}