Ensure that the library "U8g2lib" is installed and that
"U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE);"
is obtained. This is explained in the video - obtained from one of the example files.
#include <U8g2lib.h>
#include <Wire.h>
U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE);
int x_1 = 28; // for "subscribe to" text coordinates
int x_3 = -80; // for "subscribe to" text coordinates
int x_2 = 22; //for "Ware Explained" text coordinates
int x_4 = -90; //for "Ware Explained" text coordinates
void setup() {
Serial.begin(9600);
u8g2.begin();
}
void loop() {
u8g2.clearBuffer();
u8g2.setFontMode(1);
u8g2.setBitmapMode(1);
u8g2.setFont(u8g2_font_6x12_tr);
if(x_1 >= 127){ //for text "subscribe to"
x_1 =-80;
}
if(x_3 >= 127) {
x_3 = -80;
}
if( x_1 <= 127) { //reset first text in same row
x_1++;
Serial.print("first text reset1: ");
Serial.println(x_1);
u8g2.drawStr(x_1, 16, "Subscribe to");
}
if(x_3 <= 127){ //reset first text in same row
x_3++;
Serial.print("first text reset2: ");
Serial.println(x_3);
u8g2.drawStr(x_3, 16, "Subscribe to");
} //for text "subscribe to"
if(x_2 >= 127){ //for text "ware explained"
x_2 =-80;
}
if(x_4 >= 127) {
x_4 = -80;
}
if( x_2 <= 127) {
x_2++;
Serial.print("second text reset1: ");
Serial.println(x_2);
u8g2.drawStr(x_2, 23, "Ware Explained");
}
if(x_4 <= 127){
x_4++;
Serial.print("second text reset2: ");
Serial.println(x_4);
u8g2.drawStr(x_4, 23, "Ware Explained");
} //for text "ware explained"
//yellow color section
u8g2.drawLine(0, 0, 127, 0); //horiztonal upper
u8g2.drawLine(0, 0, 0, 6); //vertical left
u8g2.drawLine(127, 0, 127, 6); //vertical right
//blue color section
u8g2.drawLine(0, 24, 126, 24); //horizontal upper
u8g2.drawLine(0, 63, 126, 63); //horizontal lower
u8g2.drawLine(0, 63, 0, 24); //vertical left
u8g2.drawLine(127, 63, 127, 24); //vertical right
u8g2.setFont(u8g2_font_t0_13_tr);
u8g2.drawStr(5, 45, "wareexplained.com");
u8g2.sendBuffer();
Serial.println("============");
}
The SSD1306 128x64 is similar to the 128x32 varient except with the obvious 32 extra pixels added to the height of the display. It also has 4 pins and follows the same communication protocol.
The connectivity goes as follows:
Pins on Module | Pins on Uno |
---|---|
VCC | 3.3 / 5v pin |
GND | (any) GND pin |
SDA | SDA / A4 pin |
SCL | SCL / A5 pin |