I little test which wakes up from deepsleep via user buttom click and turns on the LED.
Diff: main.cpp
- Revision:
- 0:3208dcf3974f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Thu Sep 22 13:05:35 2016 +0000
@@ -0,0 +1,31 @@
+#include "mbed.h"
+
+DigitalOut myled(LED1);
+InterruptIn event(USER_BUTTON);
+
+Serial ser(USBTX, USBRX);
+
+bool pressed = false;
+
+void KeyPressed()
+{
+ ser.printf("Key Pressed\r\n");
+ pressed = true;
+}
+
+int main() {
+ ser.baud(230400);
+ ser.printf("Hello, World\r\n");
+ event.fall(&KeyPressed);
+
+ while(1) {
+ myled = 1;
+ wait(0.2);
+ myled = 0;
+ wait(1.0);
+ if (pressed) {
+ deepsleep();
+ pressed = false;
+ }
+ }
+}
Helmut Tschemernjak