#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
const int buttonPin = 2;
volatile int buttonState = 0; //value will change
int count = 0; //button pressed
const uint8_t symbols[] = {234, 157, 153, 219}; //array of nonalphanumeric symbols, uint8_t
void setup() {
pinMode(buttonPin, INPUT);
attachInterrupt(digitalPinToInterrupt(buttonPin), buttonInterrupt, CHANGE);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.display();
}
void loop() {
if (buttonState) {
buttonState = 0;
count++;
if (count >= sizeof(symbols)) { //sizeof = amount in array
count = 0; // wraps around when it reaches the end of the array
}
display.clearDisplay();
display.setTextSize(3);
display.setTextColor(WHITE);
display.setCursor((display.width() - 12) / 2, (display.height() - 16) / 2);
display.write(symbols[count]); //ASCII Value (tables online)
display.display();
delay(1000);
}
}
void buttonInterrupt() {
buttonState = 1;
}