参考
x 過去ログを見よ!!
x 3.1.0
x Adafruit_NeoPixel.hのインストール
目的
なんかのM5Stackのミーティングで貰った。
WS2812Bの8x8で遊ぶ。
・
イメージ
//NeoPixel8x8_test1_M5NanoC6_1
//インクルド
#include <Arduino.h>
#include <Adafruit_NeoPixel.h>
//定義
#define NUM_LEDS 64
Adafruit_NeoPixel strip(NUM_LEDS, 13, NEO_GRB + NEO_KHZ800);
unsigned char Pixel[8][8][3];
int line = 7;
int column = 7;
//初期化
void setup() {
//ネオピクセルの設定
strip.begin();
//strip.setPixelColor(0, strip.Color(5, 5, 5));
strip.show();
//シリアルポートの設定
Serial.begin(115200);
for (int i = 0; i < 9; i++) {
Serial.print(".");
delay(500); //接続待ち
} //for
Serial.println();
} //main
//ネオピクセルに転送後に表示
void NeoPixe_OUT() {
//Serial.printf("line = %d\n",line);
//Serial.printf("column = %d\n",column);
int k = 0;
for (int i = 0; i < (line + 1); i++) {
for (int j = 0; j < (column + 1); j++) {
strip.setPixelColor(k, strip.Color(
Pixel[i][j][0], Pixel[i][j][1], Pixel[i][j][2]));
k++;
//strip.show();
//Serial.printf(".");
} //for j
//Serial.printf("\n");
} //for i
//Serial.printf("\n");
strip.show();
} //NeoPixe_OUT
//0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3
unsigned char hh0[8][32] = {
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
{ 64, 64, 64, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 64, 64, 64 },
{ 64, 64, 64, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 64, 64, 64 },
{ 64, 64, 64, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 64, 64, 64 },
{ 64, 64, 64, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 64, 64, 64 },
{ 64, 64, 64, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 64, 64, 64 },
{ 64, 64, 64, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 64, 64, 64 },
{ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 }
};
unsigned char hh1[8][32] = {
{ 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11 },
{ 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11 },
{ 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11 },
{ 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11 },
{ 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11 },
{ 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11 },
{ 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11 },
{ 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11 }
};
//unsigned char hh3[8][32] = {
// { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 },
// { 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5 },
// { 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5 },
// { 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5 },
// { 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5 },
// { 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5 },
// { 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5 },
// { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 }
//};
//メインループ
void loop() {
int pt;
//Serial.printf("line = %d\n",line);
//Serial.printf("column = %d\n",column);
for (int i = 0; i < (line + 1); i++) {
for (int j = 0; j < (column + 1); j++) {
pt = 3 * j;
Pixel[i][j][0] = hh0[i][pt++];
Pixel[i][j][1] = hh0[i][pt++];
Pixel[i][j][2] = hh0[i][pt];
} //for j
} //for i
NeoPixe_OUT();
delay(3000); //3秒待つ
for (int i = 0; i < (line + 1); i++) {
for (int j = 0; j < (column + 1); j++) {
pt = 3 * j;
Pixel[i][j][0] = hh1[i][pt++];
Pixel[i][j][1] = hh1[i][pt++];
Pixel[i][j][2] = hh1[i][pt];
} //for j
} //for i
NeoPixe_OUT();
delay(3000); //3秒待つ
} //loop