initial commit
This commit is contained in:
commit
f03ab40cb2
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.pio/
|
15
platformio.ini
Normal file
15
platformio.ini
Normal file
@ -0,0 +1,15 @@
|
||||
; PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter
|
||||
; Upload options: custom upload port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
; Advanced options: extra scripting
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[env:d1_mini]
|
||||
framework = arduino
|
||||
platform = espressif8266
|
||||
board = d1_mini
|
||||
lib_deps = fastled/FastLED@^3.5.0
|
50
src/main.ino
Normal file
50
src/main.ino
Normal file
@ -0,0 +1,50 @@
|
||||
#include "FastLED.h"
|
||||
#define NUM_LEDS 18 // # of LEDS in the strip
|
||||
CRGB leds[NUM_LEDS];
|
||||
#define DATA_PIN 2 // Output Pin to Data Line on Strip
|
||||
|
||||
// Change effect here
|
||||
#define DELAY 200
|
||||
|
||||
///////
|
||||
|
||||
int fadeAmount = 1; // Set the amount to fade I usually do 5, 10, 15, 20, 25 etc even up to 255.
|
||||
int brightness = 0;
|
||||
int fade_switch = 0;
|
||||
|
||||
void setup() {
|
||||
FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
|
||||
}
|
||||
|
||||
int colors[3][3] = { { 255, 0, 0 }, { 0, 255, 0 }, { 0, 0, 255 } };
|
||||
int counter = 0;
|
||||
int color_index = 0;
|
||||
|
||||
void loop() {
|
||||
for(int i = 0; i < NUM_LEDS; i++ )
|
||||
{
|
||||
leds[i].setRGB(colors[color_index][0],colors[color_index][1],colors[color_index][2]);
|
||||
leds[i].fadeLightBy(brightness);
|
||||
}
|
||||
FastLED.show();
|
||||
brightness = brightness + fadeAmount;
|
||||
// reverse the direction of the fading at the ends of the fade:
|
||||
if(brightness == 0 || brightness == 255)
|
||||
{
|
||||
fadeAmount = -fadeAmount;
|
||||
}
|
||||
if(brightness == 255)
|
||||
{
|
||||
fade_switch = fade_switch+1;
|
||||
}
|
||||
if(fade_switch == 1) {
|
||||
fade_switch = 0;
|
||||
counter = counter + 1;
|
||||
color_index = counter % 3;
|
||||
}
|
||||
if (counter >= 2048) {
|
||||
counter = 0;
|
||||
}
|
||||
delay(DELAY);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user