文書の表示以前のリビジョンバックリンク文書の先頭へ この文書は読取専用です。文書のソースを閲覧することは可能ですが、変更はできません。もし変更したい場合は管理者に連絡してください。 ====== Neopixel ====== ここではNeopixelと呼ばれるシリアルICチップで個別に制御可能なLEDモジュールをM5StickCを利用して動作させてみます. まずはExampleを利用して動作を確認してみます. <html> <div style="position: relative; padding-bottom: 62.5%; height: 0;"><iframe src="https://www.loom.com/embed/545fd801393640789297412ed4379d52" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"></iframe></div> </html> ====== 個別に光らせてみる ====== なんかExampleのコード難しくなかったですか? 動きはしたんですが,コードが良くないんで,このページでは個別に制御するための方法を紹介します.一緒にやってみましょう. <html> <div style="position: relative; padding-bottom: 62.5%; height: 0;"><iframe src="https://www.loom.com/embed/9c1bab7a75344636b409dde51f775623" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"></iframe></div> </html> <code> /* Please install FastLED library first. In arduino library manage search FastLED */ #include <M5StickC.h> #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<WS2811,Neopixel_PIN,GRB>(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); } </code> ちなみにRGBの色を数値で指定したい場合は, leds[0] = CRGB(255,0,0); // 赤色指定 とすればOKです. ====== Reference ====== FastLED Library: http://fastled.io ---- {{indexmenu>:arduino:m5stickc#1|js#indextheme navbar}} /home/users/2/lolipop.jp-4404d470cd64c603/web/ws/data/pages/arduino/m5stickc/06.neopixel.txt 最終更新: 2020/09/07 09:29by baba