홈>
millis를 사용하여 2 초마다 led가 깜박이려고합니다. 다른 센서가 작동 중이므로 지연이 불가능합니다.
지금까지 나는 이것을 얻었지만 작동하지 않는 것 같습니다.
#include "FastLED.h"
#define NUM_LEDS 12 // number of LEDS in neopixel ring
#define DATA_PIN 10 // for neopixel ring
CRGB leds[NUM_LEDS];
long period = 2000;
long currentMillis = 0;
long startMillis = 0;
void setup() {
FastLED.addLeds<WS2812, DATA_PIN, RGB>(leds, NUM_LEDS);
}
void loop() {
currentMillis = millis();
if (currentMillis - startMillis >= period) {
startMillis = currentMillis;
leds[7]=CRGB(255,0,0);
FastLED.show();
}
}
- 답변 # 1
좀 더 가까이 가나 요?