#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET 4
#define SCREEN_ADDRESS 0x3D
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
const int buttonPin1 = 2;
const int buttonPin2 = 3;
const int buttonPin3 = 1;
volatile int buttonCode = 3;
void ISR_button1Pressed() {
//buttonCode = 64;
buttonCode++;
}
void ISR_button2Pressed() {
buttonCode = 36;
}
void ISR_button3Pressed() {
buttonCode = 3;
}
void setup() {
Serial.begin(9600);
pinMode(buttonPin1, INPUT_PULLUP);
pinMode(buttonPin2, INPUT_PULLUP);
pinMode(buttonPin3, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(buttonPin1), ISR_button1Pressed, FALLING);
attachInterrupt(digitalPinToInterrupt(buttonPin2), ISR_button2Pressed, FALLING);
attachInterrupt(digitalPinToInterrupt(buttonPin3), ISR_button3Pressed, FALLING);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();
display.setTextSize(8);
display.setTextColor(WHITE);
}
void loop() {
display.clearDisplay();
display.setCursor(0, 0);
display.write(buttonCode);
display.display();
delay(100);
}