#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
/*
* Connections
* SSD1306 OLED | Arduino Uno
* ---------------------------
* VCC | +5V (Vcc/power/+ve)
* GND | GND (Ground/-ve/0v)
* SCL | A5 (Serial Clock Line)
* SDA | A4 (Serial Data Line)
*/
const int SCREEN_WIDTH = 128; // OLED display width, in pixels
const int SCREEN_HEIGHT = 64; // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
// 'temp', 10x20px
const unsigned char epd_bitmap_temp [] PROGMEM = {
0x00, 0x00, 0x1c, 0x00, 0x36, 0x00, 0x22, 0x00, 0x22, 0x00, 0x22, 0x00, 0x22, 0x00, 0x22, 0x00,
0x2a, 0x00, 0x2a, 0x00, 0x2a, 0x00, 0x2a, 0x00, 0x6b, 0x00, 0x5d, 0x00, 0xdd, 0x80, 0xdd, 0x80,
0x5d, 0x00, 0x63, 0x00, 0x3e, 0x00, 0x00, 0x00
};
// 'hum', 12x20px
const unsigned char epd_bitmap_hum [] PROGMEM = {
0x00, 0x00, 0x06, 0x00, 0x07, 0x00, 0x0f, 0x00, 0x1f, 0x80, 0x1f, 0xc0, 0x3f, 0xc0, 0x3f, 0xe0,
0x7f, 0xe0, 0x7f, 0xe0, 0x7f, 0xf0, 0xff, 0xf0, 0x7f, 0xf0, 0x7f, 0xe0, 0x7f, 0xe0, 0x3f, 0xc0,
0x1f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'luz', 35x38px
const unsigned char epd_bitmap_luz [] PROGMEM = {
0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00,
0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00,
0x00, 0x0c, 0x00, 0x03, 0x83, 0xf8, 0x1c, 0x00, 0x01, 0x8f, 0xfe, 0x18, 0x00, 0x00, 0x1f, 0xbf,
0x80, 0x00, 0x00, 0x3c, 0x03, 0x80, 0x00, 0x00, 0x70, 0x01, 0xc0, 0x00, 0x00, 0xe0, 0x00, 0xe0,
0x00, 0x00, 0xe0, 0x00, 0x60, 0x00, 0x01, 0xc0, 0x00, 0x70, 0x00, 0x01, 0xc0, 0x00, 0x70, 0x00,
0x31, 0xc0, 0x00, 0x31, 0xc0, 0x79, 0x80, 0x00, 0x33, 0xe0, 0x01, 0xc0, 0x00, 0x30, 0x00, 0x01,
0xc0, 0x00, 0x30, 0x00, 0x01, 0xc0, 0x00, 0x70, 0x00, 0x00, 0xe0, 0x00, 0x70, 0x00, 0x00, 0xe0,
0x00, 0xe0, 0x00, 0x00, 0x70, 0x01, 0xc0, 0x00, 0x00, 0x70, 0x01, 0xc0, 0x00, 0x00, 0x38, 0x03,
0x90, 0x00, 0x01, 0x9c, 0x07, 0x38, 0x00, 0x03, 0x1f, 0xff, 0x1c, 0x00, 0x06, 0x0f, 0xfe, 0x0c,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xfc, 0x00, 0x00,
0x00, 0x07, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0xf0, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00
};
void setup() {
Serial.begin(9600);
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
Serial.println(F("SSD1306 allocation failed"));
while(true);
}
}
void loop() {
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 2);
// Display static text
// display.println("Hello, World!");
// display.drawBitmap(0, 6, epd_bitmap_BICI, 128, 64, WHITE);
display.drawBitmap(0, 0, epd_bitmap_temp, 10, 20, WHITE);
display.setCursor(12, 2);
display.setTextSize(2);
// Display static text
display.print("20");
display.drawBitmap(0, 30, epd_bitmap_hum, 12, 20, WHITE);
//display.drawBitmap(0, 6, epd_bitmap_BICI, 128, 64, WHITE);
display.display();
}Loading
ssd1306
ssd1306