Im trying to get the below to change to a separate Void function but using the buttons and have the loop stay until the button is pressed, idea behind this is so i can change the display to a different loop function.
The below works in as much as i can select the sketch i want, but it seems to block the loop and i have to cycle through the buttons...
Main sketch
#include <Arduino.h>
#define LILYGO_T5_V213
#include "boards.h"
int buttonPin1 = 39;
int buttonPin2 = 38;
int buttonPin3 = 37;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(buttonPin1, INPUT_PULLUP);
pinMode(buttonPin2, INPUT_PULLUP);
pinMode(buttonPin3, INPUT_PULLUP);
}
void loop() {
// put your main code here, to run repeatedly:
while (digitalRead(buttonPin1) == HIGH) {
Screen1();
}
while (digitalRead(buttonPin2) == HIGH) {
Screen2();
}
while (digitalRead(buttonPin3) == HIGH) {
Screen3();
}
}
i managed to get it to work this way ,, but im certain this is not very clean
#include <Arduino.h>
#define LILYGO_T5_V213
#include "boards.h"
int buttonPin1 = 37;
int buttonPin2 = 38;
int buttonPin3 = 39;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
delay(1000);
if (digitalRead(buttonPin1) == LOW) {
Screen1();
}
if (digitalRead(buttonPin2) == LOW) {
Screen2();
}
if (digitalRead(buttonPin3) == LOW) {
Screen3();
}
}