Есть проект который нужно дописать короче говоря есть код в котором при определенном сценарии свето диоды светят разными цветами а мне нужно что бы они или мигали или бегали как бегущая дорожка с каким-то интервалом.
#include <ESP8266WiFiMulti.h>
#include <ArduinoJson.h>
#include <Adafruit_NeoPixel.h>
//#include <SPI.h>
//#include <Wire.h>
#define LED_PIN 3 //
#define LED_COUNT 25
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
DynamicJsonDocument doc(20000);
String baseURL = " адрес ";
static String states[] = ...... Тут значение
static unsigned long times[25];
static int ledColor[25];
int arrAlarms = sizeof(ledColor) / sizeof(int);
int arrSize = sizeof(states) / sizeof(String);
//час оновлення карти 10000(10 секунд)
int period = 10000;
unsigned long last_time;
static int alarmsNowCount = 0;
static int prevAlarms = 0;
static bool beepDis = true;
static bool wifiConnected;
static bool firstUpdate = true;
char* ssid = "SSID_Name"; //
char* password = "SSID_PassWord"; // пароль вайфай
void setup() {
Serial.begin(9600);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting wifi..");
}
Serial.println("Start display");
//
Serial.println("End display");
Serial.println("Start strip...");
strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
strip.show(); // Turn OFF all pixels ASAP
strip.setBrightness(50); // (max = 255)
colorWipe(strip.Color(0, 255, 0), 50);
Serial.println("End strip");
}
void colorWipe(uint32_t color, int wait) {
for (int i = 0; i < strip.numPixels(); i++) { // For each pixel in strip...
strip.setPixelColor(i, color); // Set pixel's color (in RAM)
strip.show(); // Update strip to match
delay(wait); // Pause for a moment
}
}
void loop() {
wifiConnected = WiFi.status() == WL_CONNECTED;
// Serial.println("loop");
if (wifiConnected) {
if (millis() - last_time > period || firstUpdate) {
firstUpdate = false;
String response;
Serial.println("Start Get");
HTTPClient http;
WiFiClient wifiClient;
//wifiClient.setInsecure();
http.setUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36");
http.begin(wifiClient, baseURL.c_str());
// Send HTTP GET request
int httpResponseCode = http.GET();
Serial.print("Get code:");
Serial.println(httpResponseCode);
if (httpResponseCode == HTTP_CODE_OK || httpResponseCode == HTTP_CODE_MOVED_PERMANENTLY) {
response = http.getString();
Serial.println(response);
} else {
return;
}
// Free resources
http.end();
DeserializationError error = deserializeJson(doc, response);
if (error) {
return;
}
unsigned long t = millis();
unsigned long hv = 180000;
last_time = t;
alarmsNowCount = 0;
for (int i = 0; i < arrSize; i++) {
bool enable = false;
String stateEnable = doc[states[i]]["location"].as<String>();
if (stateEnable == states[i]) enable = true;
if (enable && times[i] == 0) {
times[i] = t;
ledColor[i] = 2;
} else if (enable && times[i] + hv > t && ledColor[i] != 1) {
ledColor[i] = 2;
} else if (enable) {
ledColor[i] = 1;
times[i] = t;
}
if (!enable && times[i] + hv > t && times[i] != 0) {
ledColor[i] = 3;
} else if (!enable) {
ledColor[i] = 0;
times[i] = 0;
}
if (ledColor[i] == 1 || ledColor[i] == 2) {
alarmsNowCount++;
}
Serial.println(ledColor[i]);
switch (ledColor[i]) {
case 0: strip.setPixelColor(i, strip.Color(0, 0, 0)); break;
case 1: strip.setPixelColor(i, strip.Color(255, 0, 0)); break;
case 2: strip.setPixelColor(i, strip.Color(255, 55, 0)); break;
case 3: strip.setPixelColor(i, strip.Color(0, 255, 0)); break;
}
strip.show();
}
// Serial.println("beep true");
// beepDis = true;
}
} else {
//Если нет wifi
Serial.println("disconnect");
if (beepDis) {
strip.clear();
strip.show();
}
beepDis = false;
//restart after 10 sec
delay(10000);
ESP.restart();
}
}
И нужно поменять для этой строчки
case 1: strip.setPixelColor(i, strip.Color(255, 0, 0)); break;
case 2: strip.setPixelColor(i, strip.Color(255, 55, 0)); break;
case 3: strip.setPixelColor(i, strip.Color(0, 255, 0)); break;
Заранее очень благодарен!!!