#include "FastLED.h" // FastLED library.
// Fixed definitions cannot change on the fly.
#define LED_PIN 2 // Data pin to connect to the strip.
#define NUM_LEDS 13 // Number of LED's.
#define kier_L 3
#define BEAT_RATE 60
struct CRGB leds[NUM_LEDS]; // Initialize our LED array.
#define LED_PIN 6
#define NUM_LEDS 10
#define BRIGHTNESS 100
#define FADE_DELAY 30
#define SPEED 1
#define BEAT_RATE 60
uint8_t b_wave = 0; //sinus do roznych rzeczy
uint32_t starting_millis; //zmienna do zerowania sinusa
uint8_t bpm = 60; //tempo kierunkowskazu
uint16_t period = (60/bpm)*1000; //ile trwa okres w [ms]
bool one_cycle = 0;
bool high = 0;
uint8_t beat;
void setup() {
Serial.begin(115200); // Initialize serial port for debugging.
delay(100); // Soft startup to ease the flow of electrons.
pinMode(kier_L, INPUT);
FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
FastLED.clear(true);
beat = beatsin8(BEAT_RATE, 0, 255); // Generate beat value using beatsin8()
}
void loop() {
if (digitalRead(kier_L))
{
// Wandering light effect
for (int i = 0; i < NUM_LEDS + 4; i++) {
// Update LEDs
for (int j = 0; j < NUM_LEDS; j++) {
// Calculate brightness based on distance from wandering light
int distance = abs(j - i);
int brightness = constrain(255 - distance * 60 + beat, 0, 255); // Add beat effect
// Apply fade in and fade out effect
if (distance < 3) {
brightness = map(distance, 0, 2, 0, brightness);
}
// Set LED color
leds[j] = CRGB(brightness, brightness, brightness);
}
// Show updated LEDs
FastLED.show();
}
}
}