#include< FastLED.h>
int sound_value;
#define NUM_LEDS 30 //灯珠数
#define LED_PIN 2
#define ANALOG_READ 35
CRGB leds[NUM_LEDS];
void setup(){
Serial.begin(9600);
FastLED.setBrightness(30);
FastLED.addLeds<WS2812B, LED_PIN, RGB>(leds, NUM_LEDS);
}
void loop() {
sound_value = analogRead(ANALOG_READ);
if(sound_value > 2000&& sound_value< 2200){
for (int i = 0; i< = 10; i++)
leds[i] = CRGB(255, 0, 0); //五分之一的灯珠绿光
for (int j = 11; j< = NUM_LEDS; j++)
leds[j] = CRGB(0, 0, 0);
FastLED.show();
delay(15);
}
if(sound_value > 2400&& sound_value< 2600){
for (int i = 0; i< = 18; i++)
leds[i] = CRGB(0, 0, 255); //五分之二的灯珠蓝光
for (int j = 19; j< = NUM_LEDS; j++)
leds[j] = CRGB(0, 0, 0);
FastLED.show();
delay(15);
}
if(sound_value > 2800&& sound_value< 3000){
for (int i = 0; i< = 26; i++)
leds[i] = CRGB(0, 125, 125); //五分之三的灯珠紫光
for (int j = 27; j< = NUM_LEDS; j++)
leds[j] = CRGB(0, 0, 0);
FastLED.show();
delay(15);
}
if(sound_value > 3200&& sound_value< 3400){
for (int i = 0; i< = 34; i++)
leds[i] = CRGB(125, 125, 0); //五分之四的灯珠黄光
for (int j = 35; j< = NUM_LEDS; j++)
leds[j] = CRGB(0, 0, 0);
FastLED.show();
delay(15);
}
if(sound_value > 3500){
for (int i = 0; i< = NUM_LEDS; i++)
leds[i] = CRGB(0, 255, 0); //全部红光
FastLED.show();
delay(5);
}
}
int sound_value;
#define NUM_LEDS 30 //灯珠数
#define LED_PIN 2
#define ANALOG_READ 35
CRGB leds[NUM_LEDS];
void setup(){
Serial.begin(9600);
FastLED.setBrightness(30);
FastLED.addLeds<WS2812B, LED_PIN, RGB>(leds, NUM_LEDS);
}
void loop() {
sound_value = analogRead(ANALOG_READ);
if(sound_value > 2000&& sound_value< 2200){
for (int i = 0; i< = 10; i++)
leds[i] = CRGB(255, 0, 0); //五分之一的灯珠绿光
for (int j = 11; j< = NUM_LEDS; j++)
leds[j] = CRGB(0, 0, 0);
FastLED.show();
delay(15);
}
if(sound_value > 2400&& sound_value< 2600){
for (int i = 0; i< = 18; i++)
leds[i] = CRGB(0, 0, 255); //五分之二的灯珠蓝光
for (int j = 19; j< = NUM_LEDS; j++)
leds[j] = CRGB(0, 0, 0);
FastLED.show();
delay(15);
}
if(sound_value > 2800&& sound_value< 3000){
for (int i = 0; i< = 26; i++)
leds[i] = CRGB(0, 125, 125); //五分之三的灯珠紫光
for (int j = 27; j< = NUM_LEDS; j++)
leds[j] = CRGB(0, 0, 0);
FastLED.show();
delay(15);
}
if(sound_value > 3200&& sound_value< 3400){
for (int i = 0; i< = 34; i++)
leds[i] = CRGB(125, 125, 0); //五分之四的灯珠黄光
for (int j = 35; j< = NUM_LEDS; j++)
leds[j] = CRGB(0, 0, 0);
FastLED.show();
delay(15);
}
if(sound_value > 3500){
for (int i = 0; i< = NUM_LEDS; i++)
leds[i] = CRGB(0, 255, 0); //全部红光
FastLED.show();
delay(5);
}
}
相关帖子
- • 网购arduino UNO开发板(坏板)修复过程
- • Arduino UNO+AS608指纹识别模块+oled显示屏,实现对指纹的添加、删除、验证
- • Arduino若干模块例程 OLED DHT11 HC-SR04 BH1750 MQ-2 joystick双轴 MPU6050 RFID
- • arduino软件问题求助文件打不开了突然这样了怎么找回原来的文件
- • 使用Arduino mega 2560R3编程控制12条RGB流水灯带是否可行?
- • 关于MATLAB控制Arduino
- • esp32在arduino平台如何设置主频
- • 求助:单片机串口读取设备数据,为何有一个1秒延时?奉上全部身家
- • 自己写的max6675驱动库 Arduino源程序
- • labview控制arduino报错错误5002发生于init.vi unable to establish connection wi...