#include <FastLED.h>
#define NUM_LEDS 60
#define DATA_PIN 4
#define LED_TYPE WS2812
#define COLOR_ORDER GRB
uint8_t max_bright = 128;
uint8_t val =analogRead(A0);
CRGB leds[NUM_LEDS];
void setup() {
Serial.begin(9600);
delay(500);
LEDS.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds,NUM_LEDS);
FastLED.setBrightness(max_bright);
}
void loop(){
int val =analogRead(A0); //这里接了个声音传感器
if(val>=900){ //我想让只要识别到大于900 就执行下面的循环,但现在是每次识别到900以后就得等下面的循环结束后才开始再次识别而不是一直识别一直有循环开始
for(int a=0;a<=60;a++){
leds[a]= CRGB::White;
FastLED.show();
delay(25);
leds[a-1]=CRGB::Black;
FastLED.show();
delay(25);
}
}
Serial.print("val = ");
Serial.println(val);
Serial.println("");
delay(25);
}
求助大佬!
最新推荐文章于 2024-10-28 22:34:40 发布