//arduino equiv of wire.h library
#include <Wire.h>
#include <SPI.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
#define OLED_RESET 4
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
#define I2C_ADDRESS 0x3C;
// Reset pin # (or -1 if sharing Arduino reset pin)
// set volatile
const char symbols[] = {"@", "!", "#", "$", "%"};
volatile boolean x = false;
void setup() {
// put your setup code here, to run once:
Wire.begin();
Serial.begin(9600);
pinMode(2, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(2), dispSymbol, FALLING);
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
delay(2000);
display.clearDisplay();
delay(100);
}
void dispSymbol(){
Serial.println("interrupt");
x = true;
}
void loop() {
// put your main code here, to run repeatedly:
if (x!= false) {
display.clearDisplay();
display.setTextSize(5);
display.setTextColor(WHITE);
display.setCursor(0, 0);
display.println(symbols[1]);
display.display();
}
}
// now display this on LED