Skip to content

Instantly share code, notes, and snippets.

@gn-spawn
Created May 16, 2020 14:07
Show Gist options
  • Save gn-spawn/96ddab81d5b8a0ef4941ac9fd55fbab1 to your computer and use it in GitHub Desktop.
Save gn-spawn/96ddab81d5b8a0ef4941ac9fd55fbab1 to your computer and use it in GitHub Desktop.
pio
#include <M5Stack.h>
int state = LOW;
void setup() {
// put your setup code here, to run once:
M5.begin();
pinMode(GPIO_NUM_10, OUTPUT);
pinMode(GPIO_NUM_32, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
if(digitalRead(GPIO_NUM_32)) {
if(state == LOW) {
state = HIGH;
}
} else {
if(state == HIGH) {
state = LOW;
}
}
digitalWrite(GPIO_NUM_10, state);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment