I am trying to code an OLED which consists of 2 buttons interfaced. The working is as follows:
With the first button press it should switch on the OLED, show the opening screen.
Then by pressing the 2nd button each time it should keep on changing its screen accordingly.
I have got to make it work for the first button. But the real problem is I am not sure how to make other screens switch with a single button is pressed each time.
You first need to map the buttons to the variables.
on first button press the first variable should be set, and the second button can be mapped as a counter which counts the number of presses. based on the count you can change the screens.
ex:
bool var1;
int var2=0;
if(button1Pressed()==true){
var1=true;
switchOnOled();
}
if(var1==true&&button2pressed()==true){
var2=var2%totalScreens;
var2++;
}
switch(var2){
case 1:
screen1();
break;
case 2:
....
....
Hope that helps.