我使用WiFi获取时间显示在ws2812上,但是程序运行大约10秒后,程序显示不对,我做了测试 一边获取时间 一遍闪烁, 几秒钟后 只有第一个灯闪烁,而且颜色也不对
相关代码如下
#include <NTPClient.h>
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include <FastLED.h>
#define NUM_LEDS 14
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, "ntp.aliyun.com", 28800, 60000);
void loop() {
timeClient.update();
for(int whiteLed = 0; whiteLed < NUM_LEDS; whiteLed = whiteLed + 1)
{
leds[whiteLed] = CRGB::Red;
}
FastLED.show();
delay(300);
for(int whiteLed = 0; whiteLed < NUM_LEDS; whiteLed = whiteLed + 1)
{
leds[whiteLed] = CRGB::Black;
}
FastLED.show();
delay(300);
-------------------------------------------
如果代码 只是让灯闪烁就没问题
相关代码如下
#include <NTPClient.h>
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include <FastLED.h>
#define NUM_LEDS 14
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, "ntp.aliyun.com", 28800, 60000);
void loop() {
timeClient.update();
for(int whiteLed = 0; whiteLed < NUM_LEDS; whiteLed = whiteLed + 1)
{
leds[whiteLed] = CRGB::Red;
}
FastLED.show();
delay(300);
for(int whiteLed = 0; whiteLed < NUM_LEDS; whiteLed = whiteLed + 1)
{
leds[whiteLed] = CRGB::Black;
}
FastLED.show();
delay(300);
-------------------------------------------
如果代码 只是让灯闪烁就没问题