In this Video Tutorial we show you how to incorporate the SSD1306 OLED into your Arduino project. This is a versatile, low power display that makes it easy for you to incorporate a nice display into your Arduino projects. For this project, we connect the OLED via I2C. The schematic for our project is presented below:

Our physical build looked like this:

The video above shows in depth description of the code development, but for your convenience, we include the code below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | #include <SPI.h> #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> int screenWidth = 128; int screenHeight = 64; int oledReset = -1; #define SCREEN_ADDRESS 0x3C Adafruit_SSD1306 oled(screenWidth,screenHeight,&Wire,oledReset); void setup() { // put your setup code here, to run once: Serial.begin(9600); oled.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS); } void loop() { // put your main code here, to run repeatedly: oled.clearDisplay(); oled.display(); oled.setCursor(0,12); oled.setTextColor(WHITE); oled.setTextSize(3); oled.println(" Hello"); oled.println(" World!"); oled.display(); delay(1000); oled.invertDisplay(1); delay(1000); oled.invertDisplay(0); delay(1000); oled.clearDisplay(); oled.drawPixel(64,32,WHITE); oled.display(); delay(1000); oled.clearDisplay(); oled.drawLine(0,0,127,63,WHITE); oled.display(); delay(1000); oled.clearDisplay(); oled.drawLine(0,32,127,32,WHITE); oled.drawLine(64,0,64,63,WHITE); oled.display(); delay(1000); oled.clearDisplay(); oled.drawRect(0,0,128,64,WHITE); oled.display(); delay(1000); oled.clearDisplay(); oled.fillRect(0,0,128,64,WHITE); oled.display(); delay(1000); oled.clearDisplay(); oled.fillRect(0,0,128,64,WHITE); oled.fillRect(5,5,118,54,BLACK); oled.display(); delay(1000); oled.clearDisplay(); oled.drawCircle(64,32,31,WHITE); oled.display(); delay(1000); oled.clearDisplay(); oled.fillCircle(64,32,31,WHITE); oled.fillCircle(64,32,24,BLACK); oled.display(); delay(1000); } |