#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define PANTALLA_ANCHO 128
#define PANTALLA_ALTO 64
#define OLED_RESET -1
Adafruit_SSD1306 display(PANTALLA_ANCHO, PANTALLA_ALTO, &Wire, OLED_RESET);
int PIZ = 12;
int PDR = 13;
int x = PANTALLA_ANCHO / 2;
int y = PANTALLA_ALTO / 2;
void setup() {
pinMode(PIZ, INPUT);
pinMode(PDR, INPUT);
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
for (;;);
}
display.clearDisplay();
display.drawPixel(x, y, SSD1306_WHITE);
display.display();
}
void loop() {
if (digitalRead(PIZ) == HIGH) {
x = max(0, x - 1);
}
if (digitalRead(PDR) == HIGH) {
x = min(PANTALLA_ANCHO - 1, x + 1);
}
display.drawPixel(x, y, SSD1306_WHITE);
display.display();
delay(100);
}