/*
 * =====================功能说明=====================
 * 使用Arduino Uno开发板控制WS2812光带一个灯珠的闪烁。
 *  
 * =====================电路连接======================
 * 此示例程序中,Arduino输出控制信号引脚为3号引脚。
 * 
 */

#include "FastLED.h"            // 此示例程序需要使用FastLED库

#define NUM_LEDS 11             // LED灯珠数量
#define DATA_PIN 3              // Arduino输出控制信号引脚
#define LED_TYPE WS2812         // LED灯带型号
#define COLOR_ORDER GRB         // RGB灯珠中红色、绿色、蓝色LED的排列顺序

uint8_t max_bright = 128;       // LED亮度控制变量,可使用数值为 0 ~ 255, 数值越大则光带亮度越高

CRGB leds[NUM_LEDS];            // 建立光带leds
CRGB myRGBcolour(0,0,0);        // 自定义RGB颜色(r-Red红色亮度,g-Green绿色亮度,b-Blue蓝色亮度)
CHSV myHSVcolour(42,255,100);    // 自定义HSV颜色(h-HUE色调,s-Saturation饱和度,v-Value明亮度)

void setup() { 
  Serial.begin(9600);           // 启动串行通讯
  delay(1000);                  // 稳定性等待
  LEDS.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);  // 初始化光带 
  FastLED.setBrightness(max_bright);                            // 设置光带亮度
}

void loop() { 
for(int i = NUM_LEDS - 3; i > 0; i--){
  myHSVcolour.h = 200;                  //设置自定义颜色的色调为200(紫色)
  myHSVcolour.s = 255;                  //设置自定义颜色的饱和度为255
  myHSVcolour.v = 200;                  //设置自定义颜色的明亮度为200
  fill_solid(leds+i, 3, myHSVcolour);   //同时点亮LED灯带,从第i+1个开始点亮3个灯,颜色为myHSVcolour
  FastLED.show();                       //更新LED色彩
  delay(50);

  fill_solid(leds+i, 3, CRGB::Black);
  FastLED.show();
  delay(50);
}

for(int i = 0; i < NUM_LEDS - 3; i++){
  myRGBcolour.r = 200;                    //设置自定义颜色的红色亮度为200
  myRGBcolour.g = 150;                    //设置自定义颜色的绿色亮度为150
  myRGBcolour.b = 0;                    //设置自定义颜色的蓝色亮度为0
  fill_solid(leds+i, 3, myRGBcolour);   //同时点亮LED灯带,从第i+1个开始点亮3个灯,颜色为myRGBcolour
  FastLED.show();                       //更新LED色彩
  delay(50);

  fill_solid(leds+i, 3, CRGB::Black);
  FastLED.show();
  delay(50);
}
}
/*
CRGB 颜色名称列表
CRGB::AliceBlue  
CRGB::Amethyst  
CRGB::AntiqueWhite  
CRGB::Aqua  
CRGB::Aquamarine  
CRGB::Azure 
CRGB::Beige 
CRGB::Bisque  
CRGB::Black 
CRGB::BlanchedAlmond  
CRGB::Blue  
CRGB::BlueViolet  
CRGB::Brown 
CRGB::BurlyWood 
CRGB::CadetBlue 
CRGB::Chartreuse  
CRGB::Chocolate 
CRGB::Coral 
CRGB::CornflowerBlue  
CRGB::Cornsilk  
CRGB::Crimson 
CRGB::Cyan  
CRGB::DarkBlue  
CRGB::DarkCyan  
CRGB::DarkGoldenrod 
CRGB::DarkGray  
CRGB::DarkGreen 
CRGB::DarkKhaki 
CRGB::DarkMagenta 
CRGB::DarkOliveGreen  
CRGB::DarkOrange  
CRGB::DarkOrchid  
CRGB::DarkRed 
CRGB::DarkSalmon  
CRGB::DarkSeaGreen  
CRGB::DarkSlateBlue 
CRGB::DarkSlateGray 
CRGB::DarkTurquoise 
CRGB::DarkViolet  
CRGB::DeepPink  
CRGB::DeepSkyBlue 
CRGB::DimGray 
CRGB::DodgerBlue  
CRGB::FireBrick 
CRGB::FloralWhite 
CRGB::ForestGreen 
CRGB::Fuchsia 
CRGB::Gainsboro 
CRGB::GhostWhite  
CRGB::Gold  
CRGB::Goldenrod 
CRGB::Gray  
CRGB::Green 
CRGB::GreenYellow 
CRGB::Honeydew  
CRGB::HotPink 
CRGB::IndianRed 
CRGB::Indigo  
CRGB::Ivory 
CRGB::Khaki 
CRGB::Lavender  
CRGB::LavenderBlush 
CRGB::LawnGreen 
CRGB::LemonChiffon  
CRGB::LightBlue 
CRGB::LightCoral  
CRGB::LightCyan 
CRGB::LightGoldenrodYellow  
CRGB::LightGreen  
CRGB::LightGrey 
CRGB::LightPink 
CRGB::LightSalmon 
CRGB::LightSeaGreen 
CRGB::LightSkyBlue  
CRGB::LightSlateGray  
CRGB::LightSteelBlue  
CRGB::LightYellow 
CRGB::Lime  
CRGB::LimeGreen 
CRGB::Linen 
CRGB::Magenta 
CRGB::Maroon  
CRGB::MediumAquamarine  
CRGB::MediumBlue  
CRGB::MediumOrchid  
CRGB::MediumPurple  
CRGB::MediumSeaGreen  
CRGB::MediumSlateBlue 
CRGB::MediumSpringGreen 
CRGB::MediumTurquoise 
CRGB::MediumVioletRed 
CRGB::MidnightBlue  
CRGB::MintCream 
CRGB::MistyRose 
CRGB::Moccasin  
CRGB::NavajoWhite 
CRGB::Navy  
CRGB::OldLace 
CRGB::Olive 
CRGB::OliveDrab 
CRGB::Orange  
CRGB::OrangeRed 
CRGB::Orchid  
CRGB::PaleGoldenrod 
CRGB::PaleGreen 
CRGB::PaleTurquoise 
CRGB::PaleVioletRed 
CRGB::PapayaWhip  
CRGB::PeachPuff 
CRGB::Peru  
CRGB::Pink  
CRGB::Plaid 
CRGB::Plum  
CRGB::PowderBlue  
CRGB::Purple  
CRGB::Red 
CRGB::RosyBrown 
CRGB::RoyalBlue 
CRGB::SaddleBrown 
CRGB::Salmon  
CRGB::SandyBrown  
CRGB::SeaGreen  
CRGB::Seashell  
CRGB::Sienna  
CRGB::Silver  
CRGB::SkyBlue 
CRGB::SlateBlue 
CRGB::SlateGray 
CRGB::Snow  
CRGB::SpringGreen 
CRGB::SteelBlue 
CRGB::Tan 
CRGB::Teal  
CRGB::Thistle 
CRGB::Tomato  
CRGB::Turquoise 
CRGB::Violet  
CRGB::Wheat 
CRGB::White 
CRGB::WhiteSmoke  
CRGB::Yellow  
CRGB::YellowGreen 

*/