差分
このページの2つのバージョン間の差分を表示します。
次のリビジョン | 前のリビジョン | ||
arduino:m5stickc:06.neopixel [2020/08/15 14:41] – 作成 baba | arduino:m5stickc:06.neopixel [2020/09/07 09:29] (現在) – baba | ||
---|---|---|---|
行 5: | 行 5: | ||
<div style=" | <div style=" | ||
</ | </ | ||
+ | |||
+ | ====== 個別に光らせてみる ====== | ||
+ | なんかExampleのコード難しくなかったですか? | ||
+ | 動きはしたんですが,コードが良くないんで,このページでは個別に制御するための方法を紹介します.一緒にやってみましょう. | ||
+ | |||
+ | < | ||
+ | <div style=" | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | /* | ||
+ | Please install FastLED library first. | ||
+ | In arduino library manage search FastLED | ||
+ | */ | ||
+ | #include < | ||
+ | #include " | ||
+ | |||
+ | #define Neopixel_PIN | ||
+ | #define NUM_LEDS | ||
+ | |||
+ | CRGB leds[NUM_LEDS]; | ||
+ | uint8_t gHue = 0; | ||
+ | static TaskHandle_t FastLEDshowTaskHandle = 0; | ||
+ | static TaskHandle_t userTaskHandle = 0; | ||
+ | |||
+ | void setup() { | ||
+ | Serial.begin(115200); | ||
+ | M5.begin(); | ||
+ | // | ||
+ | M5.Lcd.setRotation(3); | ||
+ | M5.Lcd.setTextColor(YELLOW); | ||
+ | // | ||
+ | M5.Lcd.setCursor(10, | ||
+ | M5.Lcd.println(" | ||
+ | M5.Lcd.setTextColor(WHITE); | ||
+ | M5.Lcd.setCursor(0, | ||
+ | M5.Lcd.println(" | ||
+ | |||
+ | // Neopixel initialization | ||
+ | FastLED.addLeds< | ||
+ | FastLED.setBrightness(10); | ||
+ | | ||
+ | } | ||
+ | |||
+ | void loop() | ||
+ | { | ||
+ | leds[0] = CRGB::Red; | ||
+ | FastLED.show(); | ||
+ | delay(1000); | ||
+ | leds[0] = CRGB:: | ||
+ | FastLED.show(); | ||
+ | delay(1000); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ちなみにRGBの色を数値で指定したい場合は, | ||
+ | leds[0] = CRGB(255, | ||
+ | とすればOKです. | ||
+ | |||
+ | ====== Reference ====== | ||
+ | FastLED Library: http:// | ||
+ | |||
+ | ---- | ||
+ | |||
+ | {{indexmenu>: | ||