Working through how to use SLS.
I’m using SLS 1.2.0 with ESP32, TFT screen and Arduino IDE (MAC)
I’d like to learn how to assign a button action to call a function.
As a first step, how to toggle a LED on/off.
As an example of a simple button & blink function:
void loop() {
last_button_state = button_state; // save the last state
button_state = digitalRead(BUTTON_PIN); // read new state
if (last_button_state == HIGH && button_state == LOW) {
Serial.println("The button is pressed");
// toggle state of LED
led_state = !led_state;
// control LED arccoding to the toggled state
digitalWrite(LED_PIN, led_state);
}
}
Hello, thank you guys for the post, someone, could please show an complete example in how to press a button in the interface and call a function in the code ? to turn on a LED for example, i’m a very begginer :(.
With a screen, controller ili9341, touch xpt2046, i’m able to use the touch, and to call a function, but I dont know, for example, how to touch a button in the screen and turn on a GPIO, or how to touch a phisical button and change a state in the screen.