#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);
// put your setup code here, to run once:
screen.begin(SSD1306_SWITCHCAPVCC,address);
screen.clearDisplay();//clears everything off display
Serial.begin(9600);
}
int width=20;
int height = 10;
void loop() {
//parameters (x position, y position, width, height, color)
while(width<50){
screen.drawRect(screen_width/2-width/2,screen_height/2 - height/2, width,height,1);
screen.display();
width++;//width = width + 1 ...add 1 to the width
height++;//height = height +1;
printDimensions();
delay(1);
screen.clearDisplay();
}
while(width>20){
screen.drawRect(screen_width/2-width/2,screen_height/2 - height/2, width,height,1);
screen.display();
width--;//width = width + 1 ...add 1 to the width
height--;//height = height +1;
printDimensions();
delay(1);
screen.clearDisplay();
}
}
void printDimensions(){
Serial.print("Width: ");
Serial.print(width);
Serial.print(" | Height : ");
Serial.println(height);
}