#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
Adafruit_SSD1306 display(128 , 64 , &Wire ,-1);
int scroll_left_button = 2;
int scroll_right_button = 4;
int move_up_button = 16;
int move_down_button = 17;
char text[100];
int text_x = 0;
int text_y = 32;
void displaytext() {
display.clearDisplay();
display.setTextSize(3);
display.setTextColor(WHITE);
display.setCursor(text_x, text_y);
display.println(text);
display.display();
}
void setup() {
display.begin(SSD1306_SWITCHCAPVCC,0x3C);
Serial.begin(115200);
pinMode(scroll_left_button, INPUT);
pinMode(scroll_right_button, INPUT);
pinMode(move_up_button, INPUT);
pinMode(move_down_button, INPUT);
Serial.print("Enter text: ");
while (!Serial.available()) {
}
Serial.readBytesUntil('\n', text, sizeof(text));
display.clearDisplay();
}
void loop() {
displaytext();
if (digitalRead(scroll_left_button) == HIGH) {
text_x-=3;
displaytext();
}
else if (digitalRead(scroll_right_button) == HIGH) {
text_x+=3;
displaytext();
}
else if (digitalRead(move_up_button) == HIGH) {
text_y-=3;
displaytext();
}
else if (digitalRead(move_down_button) == HIGH) {
text_y+=3;
displaytext();
}
delay(50);
}