How to do a set/reset in Arduino with only one button?
(deleted)
Pablo1006:
How to do a set/reset in Arduino with only one button?
Not a lot of detail here. Set / reset what? An output an LED or the machine.
At a guess I would look at the state change detect in the File -> Examples -> 02Digital menu.
Switch LED_BUILTIN on/off with one button.
#include <Bounce2.h>
const byte button = 3;
const byte ledPin = LED_BUILTIN;
byte ledState = LOW;
Bounce key;
void setup() {
pinMode(ledPin, OUTPUT);
key.attach(button, INPUT_PULLUP); // button closing to GND
}
void loop() {
if (key.update() && key.fell()) {
ledState = !ledState;
}
digitalWrite(ledPin, ledState);
}
1 Like