#include <Adafruit_SSD1306.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
int address = 60; //0x3C; //means 12 (C) plus 3 16s or 48
//12 + 48 is 60.
int r_button = 2;
int l_button = 3;
int screen_width = 128;
int screen_height = 64;
//declaring my new lcd and naming it "screen
Adafruit_SSD1306 screen(screen_width,screen_height,&Wire, -1);
//(pixels wide, pixels tall, wire library, -1 is for the uno board reset pin)
void setup() {
pinMode(r_button,INPUT);
pinMode(l_button,INPUT);
Serial.begin(9600);
// put your setup code here, to run once:
screen.begin(SSD1306_SWITCHCAPVCC,address);
screen.clearDisplay();//clears everything off display
}
int x = 10;
int y = 10;
void loop() {
if (x == 10 || y == 10) {
screen.drawRect(screen_width/2-x/2,screen_height/2-y/2,x,y,1);
screen.display();
x++;
y++;
}
if (x > random(120,128)) {
while ( x > 10) {
x--;
}
if (y > random(60,64)) {
while ( y > 10) {
y--;
}
}
delay(4);
screen.clearDisplay();
printWH();
}
}
void printWH(){
Serial.print("width: ");
Serial.print(x);
Serial.print(" height: ");
Serial.println(y);
}