/*
begin()
updateLength()
updateType()
show()
delay_ns()
setPin()
setPixelColor()
fill()
ColorHSV()
getPixelColor()
setBrightness()
getBrightness()
clear()
gamma32()
*/
#include <Adafruit_NeoPixel.h>
#define STRIP_PIN 4
#define NUM_LEDS 12
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, STRIP_PIN);
volatile int brightness = 50; // Начальная яркость (от 0 до 255)
volatile bool is_running = true;
int left_button = 7;
int right_button = 3;
int middle_button = 2;
void setup() {
strip.begin();
strip.show();
pinMode(left_button, INPUT_PULLUP);
pinMode(right_button, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(left_button), decreaseBrightness, RISING);
attachInterrupt(digitalPinToInterrupt(right_button), increaseBrightness, RISING);
attachInterrupt(digitalPinToInterrupt(middle_button), light, RISING);
}
void loop() {
delay(100);
if(is_running)
{
strip.setBrightness(brightness);
strip.fill(strip.Color(0, 0, 255));
strip.show();
}
else{
strip.clear();
strip.show();
}
}
void increaseBrightness() {
if (brightness < 255) {
brightness += 10; // Увеличьте на сколько угодно
}
}
void decreaseBrightness() {
if (brightness > 0) {
brightness -= 10; // Уменьшьте на сколько угодно
}
}
void light()
{
is_running = !is_running;
}
void colorWipe(uint32_t color, int wait) {
strip.setBrightness(brightness);
for(int i = 0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, color);
strip.show();
delay(wait);
}
}