0.96 Inch 4Pin White IIC I2C OLED Display Module 12864 LED For Arduino £4.51
0.96 Inch Display 128x64
OLED Driver IC: SSD1306
Resolution: 128 x 64
Visual Angle: >160°
Input Voltage: 3.3V ~ 6V
Compatible I/O Level: 3.3V, 5V
Mini Size: 2.7 x 2.8cm
Only Need 2 I/O Port to Control
Full Compatible Arduino, 51
Adafruit_SSD1306 the code is on Github. (May need to rename the library to import it without the _ )
Note: I2C address = 0x3C.
#include "Adafruit_SSD1306/Adafruit_SSD1306.h" /* ============== MAIN =====================*/ //Use I2C with OLED RESET pin on D4 #define OLED_RESET D4 Adafruit_SSD1306 oled(OLED_RESET); unsigned long previousMillis; unsigned long interval = 30000; void setup() { oled.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3D (for the 128x64) // init done //oled.display(); // show splashscreen Time.zone(0); }
void loop() { oled.clearDisplay(); delay(200); oled.setTextSize(2); oled.setTextColor(WHITE); oled.setCursor(0,0); oled.print(Time.hourFormat12()); oled.print(":"); oled.print(Time.minute()); oled.print(":"); oled.print(Time.second()); oled.setTextColor(BLACK, WHITE); // 'inverted' text oled.display(); delay(800); }
Or you can use U8g2 graphics library or U8x8 for text only
Arduino Monochrom Graphics Library for LCDs and OLEDs https://github.com/olikraus/u8g2/wiki
include "U8glib.h"//**************************************************// Change this constructor to match your display!!! U8GLIB_SH1106_128X64 u8g(4, 5, 6, 7); //**************************************************void setup() { u8g.setFont(u8g_font_unifont); u8g.setColorIndex(1); // Instructs the display to draw with a pixel on. } void loop() { u8g.firstPage(); do { draw(); } while( u8g.nextPage() ); delay(1000); } void draw(){ u8g.drawStr( 0, 20, "Hello World"); }