「スロット」Arduino UNOとSSD1306 128x32でパラパラマンガ


x だんだんめんどくなったので過去ログを見よ

x イメージは、ランダムを使ったスロットの類


目的
OLEDのテスト
32x32のデカ文字で遊ぶ


![o_cop316.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/840352/1c2ec9ac-4a5e-a9fb-2199-ff992229ca16.jpeg)

![o_cop317.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/840352/8e40d8b1-11b4-0132-162b-c5a5fc0f4aba.jpeg)

![o_cop318.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/840352/6a6f33de-9f2a-132a-86c6-366fc0cd4b0c.jpeg)

![o_cop319.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/840352/6bf60fef-65b9-cff1-f50e-62699a0c9d8e.jpeg)





高性能ドット絵エディタ EDGE2 でパターンを作る
image2cppで変換
drawBitmapで張り付ける



```c++




//OLED_SSD1306_BITMAP128x320_SLOT1_UNO


//ヘッダーファイル
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>


//定義
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
#define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);


// ビットマップデータ
// 'soiya1', 128x320px
static const unsigned char PROGMEM databytes[] = {
  0xff, 0xf0, 0x0f, 0xff, 0xff, 0xe1, 0x87, 0xff, 0xff, 0xcf, 0xf3, 0xff, 0xff, 0x9f, 0xf9, 0xff, 
  0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 
  0xfe, 0x7f, 0xfe, 0x7f, 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 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 
  0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 
  0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xe0, 0x07, 0xff, 0xff, 0xc0, 0x03, 0xff, 
  0xff, 0xf0, 0x0f, 0xff, 0xff, 0xe1, 0x87, 0xff, 0xff, 0xcf, 0xf3, 0xff, 0xff, 0x9f, 0xf9, 0xff, 
  0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 
  0xff, 0x7f, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0xff, 
  0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xf8, 0x07, 0xff, 
  0xff, 0xf0, 0x0f, 0xff, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xcf, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 
  0xff, 0x3f, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 
  0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 
  0xfe, 0x7f, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0x1f, 0xe0, 0x7f, 0xff, 0x80, 0x00, 0x7f, 
  0xff, 0xf0, 0x0f, 0xff, 0xff, 0xe1, 0x87, 0xff, 0xff, 0xcf, 0xf3, 0xff, 0xff, 0x9f, 0xf9, 0xff, 
  0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 
  0xfe, 0x7f, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0xff, 
  0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xf0, 0x07, 0xff, 
  0xff, 0xf0, 0x07, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0xff, 0xfc, 0xff, 
  0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x3f, 
  0xff, 0xff, 0xff, 0x3f, 0xfe, 0x7f, 0xff, 0x3f, 0xfe, 0x7f, 0xff, 0x3f, 0xff, 0x3f, 0xff, 0x7f, 
  0xff, 0x3f, 0xfe, 0x7f, 0xff, 0x8f, 0xfc, 0xff, 0xff, 0xc3, 0xe1, 0xff, 0xff, 0xe0, 0x03, 0xff, 
  0xff, 0xff, 0xe7, 0xff, 0xff, 0xff, 0xc3, 0xff, 0xff, 0xff, 0xc7, 0xff, 0xff, 0xff, 0x8f, 0xff, 
  0xff, 0xff, 0x9f, 0xff, 0xff, 0xfe, 0x1f, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xfc, 0xff, 0xff, 
  0xff, 0xf0, 0xff, 0xff, 0xff, 0xe1, 0x9f, 0xff, 0xff, 0xc3, 0x9f, 0xff, 0xff, 0x87, 0x9f, 0xff, 
  0xff, 0x1f, 0x9f, 0xff, 0xff, 0x3f, 0x9f, 0xff, 0xfe, 0x3f, 0x9f, 0xff, 0xfe, 0x7f, 0x9f, 0xff, 
  0xfe, 0x7f, 0x1f, 0x7f, 0xfe, 0x00, 0x00, 0x7f, 0xfe, 0x00, 0x00, 0x7f, 0xff, 0xff, 0x9f, 0xff, 
  0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 
  0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 
  0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 
  0xff, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x7f, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 
  0xfe, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 
  0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x3f, 0xff, 0xff, 
  0xfe, 0x3f, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0x83, 0xff, 0xff, 0xff, 0xe0, 0x07, 0xff, 
  0xff, 0xf2, 0x07, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0xff, 0xfc, 0xff, 
  0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x3f, 
  0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x7f, 
  0xff, 0x3f, 0xfe, 0x7f, 0xff, 0x8f, 0xfc, 0xff, 0xff, 0xc3, 0xe1, 0xff, 0xff, 0xe0, 0x03,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0x7f, 0xff, 0x3f, 0xff, 0x3f, 0xff, 0x7f, 
  0xff, 0x3f, 0xfe, 0x7f, 0xff, 0x8f, 0xfc, 0xff, 0xff, 0xc3, 0xe1, 0xff, 0xff, 0xe0, 0x03, 0xff, 
  0xff, 0xf0, 0x0f, 0xff, 0xff, 0xe1, 0x87, 0xff, 0xff, 0xcf, 0xf3, 0xff, 0xff, 0x9f, 0xf9, 0xff, 
  0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 
  0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xff, 0x3f, 0xfe, 0x7f, 
  0xff, 0x3f, 0xfe, 0x7f, 0xff, 0x9f, 0xfe, 0x7f, 0xff, 0xcf, 0xf0, 0x7f, 0xff, 0xe0, 0x00, 0x7f, 
  0xff, 0xf0, 0x06, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 
  0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 
  0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfc, 0x7f, 0xff, 0xff, 0xfc, 0x7f, 0xff, 0xff, 0xfc, 0x7f, 
  0xff, 0xff, 0xf8, 0xff, 0xff, 0xff, 0xc1, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xfe, 0x1f, 0xff
};


//初期化
void setup() {

  // I2Cアドレスは使用するディスプレイに合わせて変更する
  display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS);

}//setup


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

  int ii;    //ループカウンター
  int i_rand = 1; //ランダム

for(ii=0;ii<30;ii++){

  // 画面表示をクリア
  display.fillScreen(BLACK);

    //ランダムの設定
    i_rand = random(10);
 
  //ビットマップの表示
  display.drawBitmap(0, 0, databytes + (i_rand*(32/8)*32), 32, 32,  WHITE);

  // 描画バッファの内容を画面に表示
  display.display();

  delay(400); //400m秒待つ

}//for ii


  delay(1000); //1秒待つ

}//loop




```