// Jeff Ritchie april 5 20206 for fab academy week 11 // initial code from chatgpt. I played around with the parameters and added code from hellobuttonblink #include //library used for I2C #include //library used for graphics #include //library used for OLED #define Button_pin D10 //establishes pin for button Adafruit_SH1107 display = Adafruit_SH1107(64, 128, &Wire); //oled display controled by wire void setup() { //setting the intiial display Serial.begin(115200); //set baud rate Wire.begin();//begin function for wire pinMode(Button_pin, INPUT_PULLUP); // button to GND display.begin(0x3C, true); //establishes the I2C address of the display display.setRotation(1); //sets the roation of the OLED display display.clearDisplay(); //clears previous display display.setCursor(0, 20); //sets where the message will start- x pixels and y pixels. 0 0 is origin display.setTextSize(2); //sets the size of the text to be displayed. 1 is smallest display.setTextColor(SH110X_WHITE); //text color display.println("Hey world"); //I couldn't fit hello world on the screen at size 2 display.display(); //displays instance above. } void loop() { if (digitalRead(Button_pin) == LOW) { //if loop if button is pressed display.clearDisplay(); //clears previous display display.setCursor(0, 10); //sets where the message will start- x pixels and 10 pixels down. 0 0 is origin display.setTextSize(1); //sets the size of the text to be displayed. display.setTextColor(SH110X_WHITE); //text color display.println("I said hey there"); // display.display(); //displays instance above. delay(200); //debounce button } else { display.clearDisplay(); //clears previous display display.setCursor(0, 20); //sets where the message will start- x pixels and y pixels. 0 0 is origin display.setTextSize(2); //sets the size of the text to be displayed. display.setTextColor(SH110X_WHITE); //text color display.println("Hey world"); //I couldn't fit hello world on the screen at size 2 display.display(); //displays instance above. } }