#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
const int y_pin = 27;
const int x_pin = 26;
const int button_pin = 16;
static const unsigned char PROGMEM obstacle1[8] = {
B10101,
B01110,
B01110,
B11111,
B01110,
B01110,
B11111,
B01110
};
void setup() {
Serial1.begin(9600);
Serial1.println("READY");
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial1.println(("SSD1306 allocation failed"));
for(;;);
}
delay(2000);
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 10);
// Display static text
display.println("Hello, world!!!");
display.display();
pinMode(y_pin, INPUT);
pinMode(x_pin, INPUT);
pinMode(button_pin, INPUT);
}
void loop() {
display.clearDisplay();
display.drawBitmap(10, 10, obstacle1, 10, 8, SSD1306_WHITE);
display.display();
Serial1.print("y: ");
Serial1.print(analogRead(y_pin));
Serial1.print(" x: ");
Serial1.println(analogRead(x_pin));
delay(1); // this speeds up the simulation
}