#include <FastLED.h>
#include <Adafruit_NeoPixel.h>
//Яркость менять только в промежутке (0-255)
#define NUM_BRIGH 255
//Длина линии звезды
#define NUM_TRAKS 5
//количество адрессных лент
#define NUM_TAPE 1
//записывать суда PIN каждой ленты
int NUM_PIN1 = 12;
int NUM_PIN2 = 6;
//Сколько всего пикселей в каждой светодиодной ленте
#define NUM_PIXELS_1 20
#define NUM_PIXELS_2 6
int NUM_PIXELS[] = {20,2};
// Минимальное и максимальное значение для перерыва между звёздами
unsigned long starDurationMIN = 100;
unsigned long starDurationMAX = 300;
int currentStarIndex = 0;
// Цвет для падющей звезды в RGB коде
CRGB leds1[NUM_PIXELS_1];
CRGB leds2[NUM_PIXELS_2];
void setup() {
randomSeed (analogRead(0));
// Initialize the NeoPixel strip
Serial.begin(9600);
FastLED.addLeds<WS2812B, NUM_PIN1, GRB>(leds1, NUM_PIXELS_1).setCorrection(TypicalLEDStrip);
FastLED.addLeds<WS2812B, NUM_PIN2, GRB>(leds2, NUM_PIXELS_2).setCorrection(TypicalLEDStrip);
// меняет яркость в соответствии со значением NUM_BRIGH
// значение яркости до 255
FastLED.setBrightness(NUM_BRIGH);
}
void loop() {
//перерыв между падающими звёздами
int delayTIME = random (starDurationMIN , starDurationMAX);
delay(delayTIME);
//Вызов функции с звездой
displayStar();
}
//Функция для падающих звёзд
void displayStar() {
// Выберает позицию для начала звезды
int NUM_UTAPE = random(NUM_TAPE );
int NUM_TAPES = NUM_TAPE ;
int starPosition = random(NUM_PIXELS[NUM_TAPES] - NUM_TRAKS);
Serial.print(NUM_UTAPE);
if (NUM_UTAPE = 0){
//Делает звёздный путь
for (int i = 0; i < NUM_TRAKS; i++, starPosition++) {
leds1[starPosition] = CHSV(0, 255, 0);;
FastLED.show();
delay(100);
}
starPosition = starPosition - NUM_TRAKS;
//уберает звёздный путь
for (int i = 0; i < NUM_TRAKS; i++, starPosition++){
leds1[starPosition] = CHSV(0,0,0);
FastLED.show();
delay(50);
}
}
if (NUM_UTAPE = 1){
//Делает звёздный путь
for (int i = 0; i < NUM_TRAKS; i++, starPosition++) {
leds2[starPosition] = CHSV(0, 255, 0);;
FastLED.show();
delay(100);
}
starPosition = starPosition - NUM_TRAKS;
//уберает звёздный путь
for (int i = 0; i < NUM_TRAKS; i++, starPosition++){
leds2[starPosition] = CHSV(0,0,0);
FastLED.show();
delay(50);
}
}
// обновление ленты
FastLED.show();
}
Почему-то ругается на FastLED.addLeds<WS2812B, NUM_PIN1, GRB>(leds1, NUM_PIXELS_1).setCorrection(TypicalLEDStrip); и
FastLED.addLeds<WS2812B, NUM_PIN2, GRB>(leds2, NUM_PIXELS_2).setCorrection(TypicalLEDStrip);
И выдаёт такую ошибку
/sketch/sketch.ino: In function ‘void setup()’:
no matching function for call to ‘CFastLED::addLeds<WS2812B, NUM_PIN1, GRB>(CRGB [20], int)’
In file included from /sketch/sketch.ino:2:0:
In file included from /sketch/sketch.ino:2:0:
In file included from /sketch/sketch.ino:2:0:
/libraries/FastLED/src/FastLED.h:267:130: note: candidate: template<ESPIChipsets CHIPSET, unsigned char DATA_PIN, unsigned char CLOCK_PIN, EOrder RGB_ORDER, long unsigned int SPI_DATA_RATE> CLEDController& CFastLED::addLeds(CRGB*, int, int)
template<ESPIChipsets CHIPSET, uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER, uint32_t SPI_DATA_RATE > CLEDController &addLeds(struct CRGB data, int nLedsOrOffset, int nLedsIfOffset = 0) {
^~~~~~~
In file included from /sketch/sketch.ino:2:0:
/libraries/FastLED/src/FastLED.h:267:130: note: candidate: template<ESPIChipsets CHIPSET, unsigned char DATA_PIN, unsigned char CLOCK_PIN, EOrder RGB_ORDER, long unsigned int SPI_DATA_RATE> CLEDController& CFastLED::addLeds(CRGB, int, int)
template<ESPIChipsets CHIPSET, uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER, uint32_t SPI_DATA_RATE > CLEDController &addLeds(struct CRGB data, int nLedsOrOffset, int nLedsIfOffset = 0) {
^~~~~~~
In file included from /sketch/sketch.ino:2:0:
/libraries/FastLED/src/FastLED.h:267:130: note: candidate: template<ESPIChipsets CHIPSET, unsigned char DATA_PIN, unsigned char CLOCK_PIN, EOrder RGB_ORDER, long unsigned int SPI_DATA_RATE> CLEDController& CFastLED::addLeds(CRGB, int, int)
template<ESPIChipsets CHIPSET, uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER, uint32_t SPI_DATA_RATE > CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
^~~~~~~
the value of ‘NUM_PIN1’ is not usable in a constant expression/sketch/sketch.ino:45:61: error: the value of ‘NUM_PIN1’ is not usable in a constant expression
FastLED.addLeds<WS2812B, NUM_PIN1, GRB>(leds1, NUM_PIXELS_1).setCorrection(TypicalLEDStrip);