1
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?

M5NanoC6、8x8 Puzzle Unit (Unit Puzzle ?)で数字を表示。

Last updated at Posted at 2025-02-09

参考

x 過去ログを見よ!!!
x 3.1.1
x フォント[9]は、6の回転版に修正
x M5Stackのミーティングで[タダ]で、貰った。
x Arduino IDEでコンパル
x WS2812B

結果

イメージ

image_original (43).jpg

プログラム





//NeoPixel8x8_0_9_M5NanoC6_1


//インクルド
#include <Arduino.h>
#include <Adafruit_NeoPixel.h>


//定義
#define MAX_X 8
#define MAX_Y 8
#define NUM_LEDS 64
Adafruit_NeoPixel strip(NUM_LEDS, 2, NEO_GRB + NEO_KHZ800);

unsigned char Pixel[8][8][3]; //キャラクターRAM(カラー)

// 'font8x8_0_9', 8x64px
unsigned char font8x8_0_9 [] =
{
  0x81, 0x7c, 0x7a, 0x76, 0x6e, 0x5e, 0x3e, 0x81, //0
  0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, //1
  0x81, 0x7e, 0xfe, 0xfe, 0xc1, 0xbf, 0x7f, 0x00, //2
  0x81, 0x7e, 0xfe, 0xc0, 0xfe, 0xfe, 0x7e, 0x81, //3
  0xe3, 0xdb, 0xbb, 0x7b, 0x00, 0xfb, 0xfb, 0xfb, //4
  0x00, 0x7f, 0x7f, 0x01, 0xfe, 0xfe, 0x7e, 0x81, //5
  0x81, 0x7e, 0x7f, 0x01, 0x7e, 0x7e, 0x7e, 0x81, //6
  0x00, 0x7e, 0xfd, 0xfb, 0xf7, 0xef, 0xdf, 0xbf, //7
  0x81, 0x7e, 0x7e, 0x81, 0x7e, 0x7e, 0x7e, 0x81, //8
  0x81, 0x7e, 0x7e, 0x7e, 0x80, 0xfe, 0x7e, 0x81, //9
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00  //: ' '
};


//ネオピクセルに転送後に表示
void NeoPixe_OUT() {

  int k = 0;
  for (int y = 0; y < MAX_Y; y++) {
    for (int x = 0; x < MAX_X; x++) {

      strip.setPixelColor(k++, strip.Color(
        Pixel[y][x][0], Pixel[y][x][1], Pixel[y][x][2]));

      //Serial.print('.');

    } //for j
    //Serial.println();
  } //for i
  //Serial.println();

  strip.show();

}  //NeoPixe_OUT


//8x8文字の表示
void ch_8x8(char ch, int c1, int c2, int c3){

  ch = (ch - '0') * 8;
  for (int y = 0; y < MAX_Y; y++) {
    int a = font8x8_0_9[ch++];
    for (int x = 0; x < MAX_X; x++) {

      if ( ((a << x) & 0x80) != 0) {
        Pixel[y][x][0] = 0;
        Pixel[y][x][1] = 0;
        Pixel[y][x][2] = 0;
      } else {
        Pixel[y][x][0] = c1;
        Pixel[y][x][1] = c2;
        Pixel[y][x][2] = c3;
      } //if

    } //for j
  } //for i

  NeoPixe_OUT(); //RBG LEDに出力

} //ch_8x8


//初期化
void setup() {

  //ネオピクセルの設定
  strip.begin();
  strip.show();

  //シリアルポートの設定
  //Serial.begin(9600);
  //Serial.println();
  //for (int i = 0; i < 9; i++) {
  //  Serial.print('.');
  //  delay(500); //接続待ち
  //} //for
  //Serial.println();

} //main


//メインループ
void loop() {

  for (int i = 0; i < 10; i++) {

    ch_8x8('0' + i, 64, 64, 64);
    delay(3000);  //3秒待つ

  } //for

} //loop


1
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
1
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?