#include <Adafruit_SSD1306.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
int right = 3;
int left = 2;
//declaring my new lcd and naming it "screen"
Adafruit_SSD1306 screen(128, 64, &Wire, -1);
//Pixles wide, pixles tall, wire library, -1 is for the uno boar reset pin)
int adress = 60; //0x3C means 12 (C) plus 3 16's or 48; 12+48=60
void setup() {
pinMode(right, INPUT);
pinMode(left, INPUT);
// put your setup code here, to run once:
screen.begin(SSD1306_SWITCHCAPVCC, adress); // adress or 60
screen.setCursor(0,10);
screen.setTextSize(1);
screen.setTextColor(1);
delay(5);
screen.fillRect(0,0,30,30,1);
screen.drawCircle(100,40,15,1);
screen.display();
delay(2000);
screen.clearDisplay();
delay(20);
Serial.begin(9600);
}
int x=0;
void loop() {
if(digitalRead(left) ==1){
x=x+1;
}
if(digitalRead(right) == 1){
x=x-1;
}
screen.fillRect(x, 0, 30, 30, 1);
screen.display();
delay(20);
screen.clearDisplay();
}
Loading
ssd1306
ssd1306