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

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

#define NUM_LEDS 7              // 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

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 = 0; i < NUM_LEDS; i++){
  leds[i] = CRGB::Red;          // 设置光带中第i个灯珠颜色为红色,leds[0]为第一个灯珠,leds[1]为第二个灯珠
  FastLED.show();                // 更新LED色彩
  delay(100);                     // 等待10毫秒 
}
  for(int i = 0; i < NUM_LEDS; i++){
  leds[i] = CRGB::Black;          // 设置光带中第i个灯珠颜色为黑色,leds[0]为第一个灯珠,leds[1]为第二个灯珠
  FastLED.show();                // 更新LED色彩
  delay(100);                     // 等待10毫秒  
}
}
/*
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 

*/