// 0x3C
#include <Wire.h>
#include <Adafruit_SSD1306.h>
#define ANCHO_PANTALLA 128
#define ALTO_PANTALLA 64
int VERT = A0;
int HORZ = A1;
int SELC = 2;
int valorVERT;
int valorHORZ;
int valorSELC;
Adafruit_SSD1306 portatil(ANCHO_PANTALLA, ALTO_PANTALLA, &Wire, -1);
void setup(){
pinMode(VERT, INPUT);
pinMode(HORZ, INPUT);
pinMode(SELC, INPUT_PULLUP);
Serial.begin(9600);
delay(300);
portatil.begin(SSD1306_SWITCHCAPVCC, 0x3C);
portatil.clearDisplay();
}
/*
void loop() {
valorVERT = analogRead(VERT);
valorHORZ = analogRead(HORZ);
valorSELC = digitalRead(SELC);
Serial.print("VERTICAL = ");
Serial.println(valorVERT);
Serial.print("HORIZONTAL = ");
Serial.println(valorHORZ);
Serial.print("PRESIONAR = ");
Serial.println(valorSELC);
// cuadrado
portatil.clearDisplay();
portatil.drawRect(59, 24, 20, 20, SSD1306_WHITE);
portatil.display();
delay(500);
if(valorVERT > 600 ){
portatil.fillRect(59, 24, 20, 20, SSD1306_WHITE);
portatil.display();
delay(500);
}
else if(valorVERT < 600){
portatil.fillRect(59, 24, 20, 20, SSD1306_WHITE);
portatil.display();
delay(500);
}
}*/
void loop(){
valorVERT = analogRead(VERT);
portatil.drawRect(59, 24, 20, 20, SSD1306_WHITE);
portatil.display();
if(valorVERT > 600){
portatil.fillRect(60, 25, 18, 18, SSD1306_WHITE);
portatil.display();
}
else if(valorVERT < 400){
portatil.fillRect(60, 25, 18, 18, SSD1306_BLACK);
portatil.display();
}
valorVERT = analogRead(HORZ);
if(valorVERT > 600){
portatil.fillRect(60, 25, 18, 18, SSD1306_WHITE);
portatil.display();
}
else if(valorVERT < 400){
portatil.fillRect(60, 25, 18, 18, SSD1306_BLACK);
portatil.display();
}
delay(100);
}