#include <EncButton.h>
EncButton<EB_TICK, 3, 2, 4> enc; // Иницилизация энкодера
#define STRIP_PIN 5 // пин ленты
#define NUMLEDS 1 // кол-во светодиодов
//#define COLOR_DEBTH 1
//#include <microLED.h> // подключаем библу
//microLED<NUMLEDS, STRIP_PIN, MLED_NO_CLOCK, LED_WS2812, ORDER_GRB> strip;
#include <FastLED.h>
#define COLOR_ORDER GRB
CRGB strip[NUMLEDS];
const CRGB colors[] = {
CRGB::Black,
CRGB::Navy,
CRGB::DarkBlue,
CRGB::MediumBlue,
CRGB::Blue,
CRGB::DarkGreen,
CRGB::Green,
CRGB::Teal,
CRGB::DarkCyan,
CRGB::DeepSkyBlue,
CRGB::DarkTurquoise,
CRGB::MediumSpringGreen,
CRGB::Lime,
CRGB::SpringGreen,
CRGB::Aqua,
CRGB::Cyan,
CRGB::MidnightBlue,
CRGB::DodgerBlue,
CRGB::LightSeaGreen,
CRGB::ForestGreen,
CRGB::SeaGreen,
CRGB::DarkSlateGray,
CRGB::DarkSlateGrey,
CRGB::LimeGreen,
CRGB::MediumSeaGreen,
CRGB::Turquoise,
CRGB::RoyalBlue,
CRGB::SteelBlue,
CRGB::DarkSlateBlue,
CRGB::MediumTurquoise,
CRGB::Indigo,
CRGB::DarkOliveGreen,
CRGB::CadetBlue,
CRGB::CornflowerBlue,
CRGB::MediumAquamarine,
CRGB::DimGray,
CRGB::DimGrey,
CRGB::SlateBlue,
CRGB::OliveDrab,
CRGB::SlateGray,
CRGB::SlateGrey,
CRGB::LightSlateGrey,
CRGB::LightSlateGray,
CRGB::MediumSlateBlue,
CRGB::LawnGreen,
CRGB::Chartreuse,
CRGB::Aquamarine,
CRGB::Maroon,
CRGB::Purple,
CRGB::Olive,
CRGB::Grey,
CRGB::Gray,
CRGB::SkyBlue,
CRGB::LightSkyBlue,
CRGB::BlueViolet,
CRGB::DarkRed,
CRGB::DarkMagenta,
CRGB::SaddleBrown,
CRGB::DarkSeaGreen,
CRGB::LightGreen,
CRGB::MediumPurple,
CRGB::DarkViolet,
CRGB::PaleGreen,
CRGB::DarkOrchid,
CRGB::Amethyst,
CRGB::YellowGreen,
CRGB::Sienna,
CRGB::Brown,
CRGB::DarkGray,
CRGB::DarkGrey,
CRGB::LightBlue,
CRGB::GreenYellow,
CRGB::PaleTurquoise,
CRGB::LightSteelBlue,
CRGB::PowderBlue,
CRGB::FireBrick,
CRGB::DarkGoldenrod,
CRGB::MediumOrchid,
CRGB::RosyBrown,
CRGB::DarkKhaki,
CRGB::Silver,
CRGB::MediumVioletRed,
CRGB::Plaid,
CRGB::IndianRed,
CRGB::Peru,
CRGB::Chocolate,
CRGB::Tan,
CRGB::LightGrey,
CRGB::Thistle,
CRGB::Orchid,
CRGB::Goldenrod,
CRGB::PaleVioletRed,
CRGB::Crimson,
CRGB::Gainsboro,
CRGB::Plum,
CRGB::BurlyWood,
CRGB::LightCyan,
CRGB::Lavender,
CRGB::DarkSalmon,
CRGB::Violet,
CRGB::PaleGoldenrod,
CRGB::LightCoral,
CRGB::Khaki,
CRGB::AliceBlue,
CRGB::Honeydew,
CRGB::Azure,
CRGB::SandyBrown,
CRGB::Wheat,
CRGB::Beige,
CRGB::WhiteSmoke,
CRGB::MintCream,
CRGB::GhostWhite,
CRGB::Salmon,
CRGB::AntiqueWhite,
CRGB::Linen,
CRGB::LightGoldenrodYellow,
CRGB::OldLace,
CRGB::Red,
CRGB::Fuchsia,
CRGB::Magenta,
CRGB::DeepPink,
CRGB::OrangeRed,
CRGB::Tomato,
CRGB::HotPink,
CRGB::Coral,
CRGB::DarkOrange,
CRGB::FairyLightNCC,
CRGB::LightSalmon,
CRGB::Orange,
CRGB::LightPink,
CRGB::Pink,
CRGB::Gold,
CRGB::PeachPuff,
CRGB::NavajoWhite,
CRGB::FairyLight,
CRGB::Moccasin,
CRGB::Bisque,
CRGB::MistyRose,
CRGB::BlanchedAlmond,
CRGB::PapayaWhip,
CRGB::LavenderBlush,
CRGB::Seashell,
CRGB::Cornsilk,
CRGB::LemonChiffon,
CRGB::FloralWhite,
CRGB::Snow,
CRGB::Yellow,
CRGB::LightYellow,
CRGB::Ivory,
CRGB::White
};
uint8_t color = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
FastLED.addLeds<WS2812, STRIP_PIN, COLOR_ORDER>(strip, NUMLEDS);
FastLED.setBrightness(255);
Serial.println(sizeof(colors)/3);
// strip.setBrightness(255);
// strip.set(0, mRGB(255, 0, 0));
// strip.leds[0] = mHSV(color, 255, 255);
// strip.show();
}
void loop() {
// put your main code here, to run repeatedly:
enc.tick();
if (enc.right()) {
color += 1;
if (color >= sizeof(colors)/3-1)
color = sizeof(colors)/3;
strip[0] = colors[color];
Serial.print(colors[color]);
Serial.println(color);
FastLED.show();
// strip.leds[0] = mHSV(color, 255, 255);
// strip.set(0, mYellow);
// strip.show();
}
if (enc.left()) {
if (color != 0)
color -= 1;
strip[0] = colors[color];
Serial.println(color);
FastLED.show();
// strip.leds[0] = mHSV(color, 255, 255);
// strip.set(0, mGreen);
// strip.show();
}
if (enc.press()) {
Serial.println("red");
color = 0;
strip[0] = CRGB::Green;
FastLED.show();
// strip.set(0, mRed);
// strip.show();
}
}