I am using an oled display with the
I am trying to create a menu on my oled (different images). I have created code that, when one button is pressed, the screen changes to the next image.
"
#include <Adafruit_SSD1306.h>
#include <splash.h>
#define bitmap_height 128
#define bitmap_width 64
#include <Wire.h>
#include <Adafruit_GFX.h>
#define YELLOW 0xFFE0
#define OLED_RESET -1
Adafruit_SSD1306 display(OLED_RESET);
int buttonState1 = 0;
const int BUTTON_PIN1 = 2;
int toggle = 0;
const unsigned char s1 [] PROGMEM = {
//image code
};
const unsigned char s2 [] PROGMEM = {
//second image code
};
void setup() {
pinMode(BUTTON_PIN1, INPUT_PULLUP);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();
}
void loop() {
buttonState1 = digitalRead(BUTTON_PIN1);
if (buttonState1 == LOW) {
if (toggle ==0) {
display.clearDisplay();
display.drawBitmap(0, 0, s1, bitmap_height, bitmap_width, WHITE);
display.display();
toggle = 1;
}
else {
display.clearDisplay();
display.drawBitmap(0, 0, s2, bitmap_height, bitmap_width, WHITE);
display.display();
toggle = 0;
}
}
}
"
(I did not include the image codes on here as they are really big, but they do work)
However, I would like to add a third image to this, so that, when you push the button, the first image is displayed, then, you press the button again, the second image is displayed, then you press the button again and the third image is displayed. How would I go about this, I have tried for hours with no success.