-
-
Save kasperkamperman/d56793a995a0496beca4ffe3ec966ed0 to your computer and use it in GitHub Desktop.
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
/* | |
INPUT_PULLUP doesn't seem to work when using the pin as an interrupt and | |
also use it to go out of sleep mode. | |
The pin floats when not attached to ground. That shouldn't happen because of the | |
internal pull-up. However the sleeping part works well from both states of the button (LOW or "floating"). | |
*/ | |
#include "application.h" | |
#pragma SPARK_NO_PREPROCESSOR | |
SYSTEM_THREAD(ENABLED); | |
SYSTEM_MODE(MANUAL); | |
void buttonPress(); | |
bool WkpValue; | |
void setup() | |
{ WiFi.off(); | |
Serial.begin(57600); | |
pinMode(WKP, INPUT_PULLUP); | |
attachInterrupt(WKP, buttonPress, CHANGE); | |
System.sleep(WKP, CHANGE); | |
} | |
void buttonPress() { | |
WkpValue = digitalRead(WKP); | |
Serial.print("p: "); | |
Serial.println(WkpValue); | |
} | |
void loop() | |
{ Serial.println("Awake"); | |
delay(500); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment