// demonstration of OLED Screen code // requires the U8glib graphics library #include "U8glib.h" U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE); // screen is 128 pixels wide, by 64 pixels high char theChar; String theMsg = "";// will store the current message int ardScore = 0; int PScore = 0; void setup(void) { Serial.begin(9600); u8g.firstPage();//load current page do {// build for the next message u8g.setFont(u8g_font_profont12); // order is (column,row) u8g.setPrintPos(50, 20); u8g.print("OLED"); } while (u8g.nextPage()); delay(3000);// leave above message on screen for 3 seconds theMsg = "Throw Down";// starting message } void makeMsg() { //the page for your message is built // column 0, row 10 u8g.setPrintPos(0, 10); u8g.print(theMsg);// the message string //column 0, row 60 u8g.setPrintPos(0, 60); u8g.print(ardScore);// Arduino's score //colunn 80, row 60 u8g.setPrintPos(80, 60); u8g.print(PScore);// player's score ardScore = ardScore + 1; PScore = PScore + 2; } void loop() { // here we get a code from the Serial monitor for a specific messags if (Serial.available() > 0) { theChar = Serial.read(); switch (theChar) { case '1': theMsg = "Message 1"; break; case '2': theMsg = "Message 2"; break; case '3': theMsg = "Message 3"; break; } } // here we load the current screen page u8g.firstPage(); do // build for the next message makeMsg(); while (u8g.nextPage()); //load the next page }