From f03ab40cb2f3755b404a726a6f39b6aac093d346 Mon Sep 17 00:00:00 2001 From: hybris Date: Fri, 18 Feb 2022 22:17:31 +0100 Subject: [PATCH] initial commit --- .gitignore | 1 + platformio.ini | 15 +++++++++++++++ src/main.ino | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 .gitignore create mode 100644 platformio.ini create mode 100644 src/main.ino diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..66fc7a3 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.pio/ diff --git a/platformio.ini b/platformio.ini new file mode 100644 index 0000000..a608b61 --- /dev/null +++ b/platformio.ini @@ -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 diff --git a/src/main.ino b/src/main.ino new file mode 100644 index 0000000..a669393 --- /dev/null +++ b/src/main.ino @@ -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(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); +} +