Ensure that the library "U8g2lib" is installed and that
"U8G2_SSD1306_128X32_UNIVISION_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_128X32_UNIVISION_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, 13, "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, 13, "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, 22, "Ware Explained");
}
if(x_4 <= 127){
x_4++;
Serial.print("second text reset2: ");
Serial.println(x_4);
u8g2.drawStr(x_4, 22, "Ware Explained");
} //for text "ware explained"
u8g2.sendBuffer();
Serial.println("============");
}
The SSD1306 128x32 pixel resolution varient paired with an I2C module allows us to present a portrait of deliberately arranged pixels to form low-res text and shapes.
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 |