#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() {
if (digitalRead(3) == 1) {
L();
}
if (digitalRead(2) == 1) {
R();
}
if (digitalRead(4) == 1) {
RL();
}
}
void printDimensions(){
Serial.print("Width: ");
Serial.print(width);
Serial.print(" | Height : ");
Serial.println(height);
}
void R() {
screen.clearDisplay();
screen.fillRect(64,0,64,64,1);
screen.drawLine(76,12,116,12,0);
screen.drawLine(96,12,96,52,0);
screen.drawLine(76,52,116,52,0);
screen.drawCircle(32,32,31,1);
screen.display();
printDimensions();
}
void L() {
screen.clearDisplay();
screen.fillRect(0,0,64,64,1);
screen.drawLine(12,12,12,52,0);
screen.drawLine(12,32,52,32,0);
screen.drawLine(52,52,52,12,0);
screen.drawCircle(96,32,31,1);
screen.display();
printDimensions();
}
void RL() {
screen.clearDisplay();
screen.fillRect(0,0,64,64,1);
screen.drawLine(12,12,12,52,0);
screen.drawLine(12,32,52,32,0);
screen.drawLine(52,52,52,12,0);
screen.fillRect(64,0,64,64,1);
screen.drawLine(76,12,116,12,0);
screen.drawLine(96,12,96,52,0);
screen.drawLine(76,52,116,52,0);
screen.display();
printDimensions();
}