#include <Wire.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h>
int Screen_width = 128;
int Screen_height = 64;
int reset = -1;
int address = 0x3C;
int X_txtpos = 35;
int Y_txtpos = 25;
int k;
Adafruit_SSD1306 display(Screen_width,Screen_height,&Wire,reset);
void setup() {
// put your setup code here, to run once:
pinMode(18,INPUT_PULLDOWN);
pinMode(19,OUTPUT);
Serial.begin(9600);
if( !display.begin(SSD1306_SWITCHCAPVCC,address))
{
Serial.println("display not connected");
for(;;);
}
display.clearDisplay();
}
void loop() {
// put your main code here, to run repeatedly:
k=digitalRead(18);
if(k==1)
{
X_txtpos += 3;
Y_txtpos = Y_txtpos;
if(X_txtpos>(Screen_width-1))
{
X_txtpos = Screen_width-1;
X_txtpos = -X_txtpos;
Y_txtpos = Y_txtpos;
}
Serial.println("Right movemennt");
delay(100);
}
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(X_txtpos,Y_txtpos);
display.print("India");
display.display();
}