首页 > 代码库 > Ardunio led呼吸灯

Ardunio led呼吸灯

#include <Adafruit_NeoPixel.h>

#define PIN 9
#define LED_NUM 16
Adafruit_NeoPixel strip = Adafruit_NeoPixel(LED_NUM, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
// put your setup code here, to run once:
strip.begin();
}

uint32_t R =0;
uint32_t G =0;
uint32_t B =0;
uint32_t color;
int bright =0;
void loop() {
uint32_t color = strip.Color(R, G, B);
int i;
for (i=0;i<LED_NUM;i++)
{
    strip.setPixelColor(i,color);
}
if (R>=255)
{
    bright=1;
}
else if (R<=0)
{
    bright=0;
}
strip.show();
delay(20);
if (bright==0)
{
    delay(100);
    R++;
    G++;
    B++;
}
else
{
    R--;
    G--;
    B--;
}
}

Ardunio led呼吸灯