Last active
September 9, 2019 14:32
-
-
Save TakuroFukamizu/3deafc0fdb3364da730e4949286e75dc to your computer and use it in GitHub Desktop.
OMRON GLS-S1 magnetic switch with M5Stack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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