Skip to content

Instantly share code, notes, and snippets.

@ksasao
Last active December 24, 2018 06:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ksasao/1c6b4ef131456a3cfc6b9d115e2543da to your computer and use it in GitHub Desktop.
Save ksasao/1c6b4ef131456a3cfc6b9d115e2543da to your computer and use it in GitHub Desktop.
M5Stack Nodeモジュールサンプルコード (LED点灯)
// ----------------------------------------------------------
// M5Stack Nodeモジュール向けLED(SK6812)操作 2018/12/24 @ksasao
// ----------------------------------------------------------
// M5Stack Fire向けの公式のコードを若干修正
// https://github.com/m5stack/M5Stack/blob/master/examples/Fire/M5StackFire_NeoPixelTest/M5StackFire_NeoPixelTest.ino
#include <M5Stack.h>
#include <Adafruit_NeoPixel.h>
#define M5STACK_NODE_NEO_NUM_LEDS 12
#define M5STACK_NODE_NEO_DATA_PIN 15
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(M5STACK_NODE_NEO_NUM_LEDS, M5STACK_NODE_NEO_DATA_PIN, NEO_GRB + NEO_KHZ800);
int pos = 0;
void setup()
{
M5.begin();
M5.Lcd.setBrightness(30);
M5.Lcd.setTextSize(2);
M5.Lcd.println("LED Test");
pixels.begin();
}
void loop()
{
UpdateLEDs();
delay(500);
}
void UpdateLEDs(){
int m = 255; // 明るさ(0 - 255)
for(int i=0; i<M5STACK_NODE_NEO_NUM_LEDS; i++){
int col = (i == pos) ? m : 0;
pixels.setPixelColor(i, pixels.Color(col, m - col, m - col));
}
pixels.show();
pos = (pos+1) % M5STACK_NODE_NEO_NUM_LEDS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment