0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

M5Stack Core2: LED の使い方

Last updated at Posted at 2021-10-03

こちらのページを参考にしました。
[M5Stack Core2 for AWS] ArduinoでLED (Adafruit NeoPixel フルカラーLED) を点灯してみました

IMG_20211003_150743.jpg

IMG_20211003_150019.jpg

image.png

led01/led01.ino
// ---------------------------------------------------------------
/*
	led01.ino

						Oct/03/2021
*/
// ---------------------------------------------------------------
#include <M5Core2.h>
#include <Adafruit_NeoPixel.h>
#define PIN 25 
#define NUMPIXELS 9 //LEDの数を指定
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); //800kHzでNeoPixelを駆動

int icount = 0;
// ---------------------------------------------------------------
void setup() {
	Serial.println("*** setup *** start ***");

	pixels.begin(); //NeoPixelの初期化

	M5.begin();
	M5.Lcd.setTextSize(3);
}

// ---------------------------------------------------------------
void loop() {
	Serial.println("*** loop *** " + String(icount));
	pixels.clear(); // NeoPixelのリセット
 
	for(int it=0; it<9; it++){
	int jt = it -1;
	if (jt < 0)
		{
		jt = 8;
	  	}

	if ((it % 3) == 0)
		{
		pixels.setPixelColor(it, pixels.Color(0, 150, 0));
		}
	   else if ((it % 3) == 1)
		{
		pixels.setPixelColor(it, pixels.Color(0, 0, 150));
		}
	else
		{
		pixels.setPixelColor(it, pixels.Color(150, 0, 0));
		}

	pixels.setPixelColor(jt, pixels.Color(0, 0, 0));
	pixels.show();	 //LEDに色を反映
	M5.Lcd.setCursor(0, 0);
	M5.Lcd.printf("LED Sample %d",it);
	delay(2000);
	icount++;
	}
}

// ---------------------------------------------------------------

Arduino 2.0.0 で確認しました。

0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?