LoginSignup
4

More than 5 years have passed since last update.

M5GOのLED-BarをArduinoで使う

Last updated at Posted at 2018-11-25

目的

M5GO/Fireの、LEDをArduinoで変えてみる。

準備

Arduinoのライブラリマネージャーから、「Adafruit_NeoPixel」をインストールします。

実装例

#include <Adafruit_NeoPixel.h>
#define PIN            15
#define NUMPIXELS      10
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
int delayval = 10; 
void setup() {
  pixels.begin(); 
}
void loop() {
  int color_r = random(255) ;
  int color_g = random(255) ;
  int color_b = random(255) ;
  for (int i = 0; i < NUMPIXELS; i++) {
    pixels.setPixelColor(i, pixels.Color(color_r, color_g, color_b)); 
    pixels.show(); 
    delay(delayval);
  }
  delay(100);
}

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4