Skip to content

Instantly share code, notes, and snippets.

@TakuroFukamizu
Last active September 9, 2019 14:32
Show Gist options
  • Save TakuroFukamizu/3deafc0fdb3364da730e4949286e75dc to your computer and use it in GitHub Desktop.
Save TakuroFukamizu/3deafc0fdb3364da730e4949286e75dc to your computer and use it in GitHub Desktop.
OMRON GLS-S1 magnetic switch with M5Stack
#include <M5Stack.h>
#define PIN_SW 2
void setup() {
M5.begin();
M5.Lcd.fillScreen(BLACK);
pinMode(PIN_SW, INPUT_PULLUP);
}
void loop() {
M5.update();
M5.Lcd.setCursor(10, 30);
M5.Lcd.setTextSize(10);
if(digitalRead(PIN_SW) == LOW) {
M5.Lcd.println("ON ");
} else {
M5.Lcd.println("OFF ");
}
delay(500);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment