// #include <Arduino.h>
// #include <Wire.h>
#include <Servo.h>
// #include <GyverEncoder.h>
#include <LiquidCrystal_I2C.h>
#include <EncButton.h>
#include <FastLED.h>
#include <OneButton.h>
#include "FastLED.h"
#define LED_PIN 10 // пин
#define LED_NUM 60 // количество светодиодов
EncButton enc(4, 3, 2);
LiquidCrystal_I2C lcd(0x27, 16, 2);
Servo myservo;
int val = 90;
CRGB leds[LED_NUM];
byte counter;
static uint32_t ledtmr;
void setup() {
// put your setup code here, to run once:
lcd.init(); // инициализация
lcd.backlight(); // включить подсветку
myservo.attach(5);
myservo.write(val);
FastLED.addLeds< WS2812, LED_PIN, GRB>(leds, LED_NUM);
FastLED.setBrightness(128);
// строки для вывода
// char s1[] = "Hello, world!";
// char s2[] = "GyverKIT";
// lcd.setCursor(1, 0);
// for (int i = 0; i < strlen(s1); i++) {
// lcd.print(s1[i]);
// delay(100);
// }
// lcd.setCursor(4, 1);
// for (int i = 0; i < strlen(s2); i++) {
// lcd.print(s2[i]);
// delay(100);
// }
// lcd.setCursor(4, 0);
// for (int i = 0; i < strlen(s2); i++) {
// lcd.print(s2[i]);
// delay(100);
// }
lcd.clear();
lcd.print(val);
}
void loop() {
// put your main code here, to run repeatedly:
// lcd.setCursor(0, 0);
enc.tick();
// if (enc.right()) {
// lcd.clear();
// val += 10;
// lcd.print(val);
// }
// if (enc.left()) {
// lcd.clear();
// val -= 10;
// lcd.print(val);
// }
if (enc.rightH()) {
lcd.clear();
val += 5;
lcd.print(val);
myservo.write(val);
}
if (enc.leftH()) {
lcd.clear();
val -= 5;
lcd.print(val);
myservo.write(val);
}
if (millis() - ledtmr >= 30) {
for (int i = 0; i < LED_NUM; i++) {
leds[i].setHue(counter + i * 255 / LED_NUM);
}
counter++; // counter меняется от 0 до 255 (тип данных byte)
FastLED.show();
ledtmr = millis();
}
// delay(30);
}