**总是要实物图,先上个纯色的,彩色的后续补。ARDUINO UNO 小清新板子。**
![IMG_20221003_102241.jpg]
![IMG_20221003_102641.jpg]
尽量让图片占更大的面积,接了三个WS2812彩灯和一个RGB彩灯和一个板载2号引脚外部中断
触摸板以及2号引脚指示灯。尽量简洁可爱的风格,可以送朋友,装饰使用。
测试代码:
```
#include <FastLED.h>
#define DATA_PIN 4 //设置引脚
#define LED_TYPE WS2812 //灯带类型
#define NUM_LEDS 3 //灯珠数量
#define COLOR_ORDER GRB //灯珠顺序
#define BRIGHTNESS 128
uint8_t max_brightness = 128; //最大亮度
int i = 0;
CRGB leds[NUM_LEDS]; // 给灯带命名
void setup() {
// put your setup code here, to run once:
FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS); //初始化灯带
FastLED.setBrightness(max_brightness); //设置灯带亮度
pinMode(2, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println(digitalRead(2));
if (digitalRead(2))
{
if(i>9)i=0;
i++;
leds[0] = CRGB(i, 0, 10 - i);
leds[1] = CRGB(10 - i, i, 0);
leds[2] = CRGB(0, 10 - i, i);
FastLED.show();
delay(10);
}
}
```