This is my code.
#include <U8glib.h>
U8GLIB_SSD1306_128X64 u8g(12, 11, 8, 9, 10);
void clear_screen();
const int pageCount = 1;
int p;
void (*pages[pageCount])() = {clear_screen};
int duration [pageCount] = {2000};
void setup() {
u8g.setFont(u8g_font_unifont);
u8g.setColorIndex(1);
p = 0;
Serial.begin(9600);
}
void loop()
{
u8g.firstPage();
do {
(*pages[p])();
} while( u8g.nextPage() );
delay(duration[p]);
p = p+1;
if (p == pageCount)
p=0;
}
void clear_screen()
{
u8g.setFont(u8g_font_unifont);
u8g.drawStr( 0, 20, "BP");
}
This is the output is a floating text which says BP starts at 20 y length and progresses towards the right after every page refresh. and moves 20 y length down as soon as it reaches the end of the OLED Check this video out. Video to the Error