Test

Fork of Nucleo-mbed-os-example-blinky by Helmut Tschemernjak

Committer:
Helmut64
Date:
Tue Jan 17 20:31:53 2017 +0000
Revision:
4:634ee710cadb
Parent:
3:a6caeb32839c
Child:
5:7db87ff5ed38
Backup

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Helmut64 0:681c27ac21c0 1 #include "mbed.h"
Helmut64 0:681c27ac21c0 2
Helmut64 4:634ee710cadb 3 DigitalOut myled(LED1);
Helmut64 4:634ee710cadb 4 InterruptIn event(USER_BUTTON);
Helmut64 4:634ee710cadb 5
Helmut64 4:634ee710cadb 6 bool pressed = false;
Helmut64 3:a6caeb32839c 7
Helmut64 4:634ee710cadb 8 void KeyPressed()
Helmut64 4:634ee710cadb 9 {
Helmut64 4:634ee710cadb 10 pressed = true;
Helmut64 4:634ee710cadb 11 }
Helmut64 0:681c27ac21c0 12
Helmut64 4:634ee710cadb 13 int main() {
Helmut64 4:634ee710cadb 14 event.fall(&KeyPressed);
Helmut64 4:634ee710cadb 15
Helmut64 4:634ee710cadb 16 while(1) {
Helmut64 4:634ee710cadb 17 myled = 1; // LED is ON
Helmut64 4:634ee710cadb 18 wait(0.2); // 200 ms
Helmut64 4:634ee710cadb 19 myled = 0; // LED is OFF
Helmut64 4:634ee710cadb 20 wait(1.0); // 1 sec
Helmut64 4:634ee710cadb 21 if (pressed) {
Helmut64 4:634ee710cadb 22 deepsleep();
Helmut64 4:634ee710cadb 23 pressed = false;
Helmut64 4:634ee710cadb 24 }
Helmut64 0:681c27ac21c0 25 }
Helmut64 0:681c27ac21c0 26 }