#include #include #include #define SCREEN_WIDTH 128 #define SCREEN_HEIGHT 64 #define OLED_RESET -1 #define SCREEN_ADDRESS 0x3C Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); const unsigned char PROGMEM rectangleBitmap[] = { // Width, Height 16, 16, // Bitmap data 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00 }; void setup() { Serial.begin(9600); if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) { Serial.println(F("SSD1306 allocation failed")); for(;;); } display.display(); delay(2000); display.clearDisplay(); // Draw rectangle display.drawRect(10, 10, 50, 30, SSD1306_WHITE); // X, Y, width, height, color // Draw bitmap display.drawBitmap(60, 10, rectangleBitmap, 32, 32, SSD1306_WHITE); display.display(); } void loop() { // Nothing to do here }