#include <FastLED.h> #define LED_PIN_1 3 #define LED_PIN_2 6 #define LED_COUNT_1 53 #define LED_COUNT_2 7 #define BRIGHTNESS 255 #define LED_TYPE WS2812B #define COLOR_ORDER GRB CRGB leds_1[LED_COUNT_1]; CRGB leds_2[LED_COUNT_2]; void setup() { FastLED.addLeds<LED_TYPE, LED_PIN_1, COLOR_ORDER>(leds_1, LED_COUNT_1); FastLED.addLeds<LED_TYPE, LED_PIN_2, COLOR_ORDER>(leds_2, LED_COUNT_2); FastLED.setBrightness(BRIGHTNESS); } void loop() { int brightness_2 = 0; int fadeAmount = 5; for (int i = 0; i < 7680; i++) { int brightness_1 = (exp(sin(i / 50.0 * PI)) - 0.36787944) * 108.0; for (int j = 0; j < LED_COUNT_1; j++) { leds_1[j].setRGB(brightness_1, brightness_1, brightness_1); } FastLED.show(); delay(20); } }灯带颜色改为红色
时间: 2024-03-21 19:38:46 浏览: 34
LED_board:将Arduino连接到LED板!
要将灯带颜色改为红色,可以将以下代码中的 `brightness_1` 值改为红色的 RGB 值,比如 `(255, 0, 0)`,表示红色的亮度值为 255,绿色为 0,蓝色为 0。
```
int brightness_1 = (exp(sin(i / 50.0 * PI)) - 0.36787944) * 108.0;
for (int j = 0; j < LED_COUNT_1; j++) {
leds_1[j].setRGB(brightness_1, brightness_1, brightness_1);
}
```
修改后的代码如下:
```
int brightness_1 = (exp(sin(i / 50.0 * PI)) - 0.36787944) * 108.0;
for (int j = 0; j < LED_COUNT_1; j++) {
leds_1[j].setRGB(255, 0, 0); // 红色的 RGB 值为 (255, 0, 0)
}
```
阅读全文