====== Neopixel ====== ここではNeopixelと呼ばれるシリアルICチップで個別に制御可能なLEDモジュールをM5StickCを利用して動作させてみます. まずはExampleを利用して動作を確認してみます.
====== 個別に光らせてみる ====== なんかExampleのコード難しくなかったですか? 動きはしたんですが,コードが良くないんで,このページでは個別に制御するための方法を紹介します.一緒にやってみましょう.
/* Please install FastLED library first. In arduino library manage search FastLED */ #include #include "FastLED.h" #define Neopixel_PIN 32 #define NUM_LEDS 15 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.clear(BLACK); M5.Lcd.setRotation(3); M5.Lcd.setTextColor(YELLOW); //M5.Lcd.setTextSize(2); M5.Lcd.setCursor(10, 2); M5.Lcd.println("Neopixel Example"); M5.Lcd.setTextColor(WHITE); M5.Lcd.setCursor(0, 15); M5.Lcd.println("Display rainbow effect"); // Neopixel initialization FastLED.addLeds(leds, NUM_LEDS).setCorrection(TypicalLEDStrip); FastLED.setBrightness(10); } void loop() { leds[0] = CRGB::Red; FastLED.show(); delay(1000); leds[0] = CRGB::Black; FastLED.show(); delay(1000); } ちなみにRGBの色を数値で指定したい場合は, leds[0] = CRGB(255,0,0); // 赤色指定 とすればOKです. ====== Reference ====== FastLED Library: http://fastled.io ---- {{indexmenu>:arduino:m5stickc#1|js#indextheme navbar}}