Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- volatile bool running = false;
- const uint8_t switch1 =3;
- const uint8_t switch2 =2;
- void setup() {
- pinMode(switch1, INPUT_PULLUP);
- pinMode(switch2, INPUT_PULLUP);
- attachInterrupt(digitalPinToInterrupt(switch1), turnOn, FALLING);
- attachInterrupt(digitalPinToInterrupt(switch2), turnOff, FALLING);
- }
- void loop() {
- if (running) {
- // Do something
- } else {
- // Do something else
- }
- }
- void turnOn() {
- running = true;
- }
- void turnOff() {
- running = false;
- }
Add Comment
Please, Sign In to add comment