#include #include U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2( U8G2_R0, /* clock=*/ 9, /* data=*/ 8, /* reset=*/ U8X8_PIN_NONE ); #define TOUCH_LEFT 4 #define TOUCH_RIGHT 5 const char* facts[] = { "Loves Gilda", "New To BCN", "From India", "FAB LAB Noob", "Loves Emotional Design", "Built This Board with sweat blood and tears", "Created Whiff", "Has Congenital Anosmia", "She/ Her/ A11y" }; const int factCount = 8; int currentFact = 0; int xPos = 95; long readTouch(int pin) { pinMode(pin, OUTPUT); digitalWrite(pin, LOW); delay(1); pinMode(pin, INPUT_PULLUP); long count = 0; while (digitalRead(pin) == LOW && count < 300) { count++; } return count; } void setup() { delay(1000); u8g2.begin(); u8g2.setFont(u8g2_font_6x12_tf); } void loop() { long left = readTouch(TOUCH_LEFT); long right = readTouch(TOUCH_RIGHT); bool touched = (left > 10) && (right > 10); u8g2.clearBuffer(); if (touched) { const char* message = facts[currentFact]; u8g2.drawStr(xPos, 40, message); // speed xPos -= 14; int textWidth = strlen(message) * 6; // next fact if (xPos < -textWidth + 31) { currentFact++; if (currentFact >= factCount) { currentFact = 0; } xPos = 95; } } else { u8g2.drawStr(40, 40, "Hold Me"); } u8g2.sendBuffer(); delay(20); }