32x32ドット4桁表示装置-仕様6(Arduino UNO)(SSD1306(128x32))


SSD1306その互換機の標準的なライブラリになっている
Adafruit SSD1306　+ Adafruit GFXのインストールする。
(0),のイメージを(0,0),に表示する




https://qiita.com/caa45040/items/f7698f087967381f91af



https://qiita.com/caa45040/items/3c57c159be0fd0f7a718



![o_cop431.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/840352/0c44b330-66e0-a480-cd2e-d8bf79ba62d0.jpeg)




```c++




//OLED_SSD1306_BITMAP32x320_0_


//ヘッダーファイル
#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, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 
  0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 
  0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0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 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, 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, 
  0xfe, 0x7f, 0xfe, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 
  0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x1f, 0xff, 0xff, 0xfe, 0x00, 0x07, 0xff, 
  0xfe, 0x00, 0x03, 0xff, 0xfe, 0x1f, 0xf3, 0xff, 0xfe, 0x3f, 0xf9, 0xff, 0xfe, 0x7f, 0xfc, 0xff, 
  0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xff, 0x3f, 0xfe, 0x7f, 0xff, 0x3f, 
  0xfe, 0x7f, 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, 
  0xfc, 0x00, 0x00, 0xff, 0xfc, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xfe, 0x3f, 0xff, 0xff, 0xfc, 0x7f, 
  0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xe3, 0xff, 
  0xff, 0xff, 0xc3, 0xff, 0xff, 0xff, 0xcf, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0x3f, 0xff, 
  0xff, 0xfe, 0x3f, 0xff, 0xff, 0xfc, 0x7f, 0xff, 0xff, 0xf8, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 
  0xff, 0xe1, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xc3, 0xff, 0xff, 0xff, 0x8f, 0xff, 0xff, 
  0xff, 0x0f, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xfe, 0x1f, 0xff, 0xff, 0xfe, 0x1f, 0xff, 0xff, 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ff, 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() {

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

  //0の表示
  display.drawBitmap(  0  ,  0  ,
    databytes + (0 * (32 / 8) * 32), 32, 32,  WHITE);

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

  delay(1000); //1秒待つ

}//loop




```