Full application

Dependencies:   mbed libTCS34725 lib_LoRaWAN

Committer:
dsubotic
Date:
Wed Jan 16 13:05:42 2019 +0000
Revision:
0:1cadcdcf4521
Child:
1:c3a839871165
STEM-2019

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dsubotic 0:1cadcdcf4521 1 #include "mbed.h"
dsubotic 0:1cadcdcf4521 2
dsubotic 0:1cadcdcf4521 3 InterruptIn button(USER_BUTTON);
dsubotic 0:1cadcdcf4521 4
dsubotic 0:1cadcdcf4521 5 DigitalOut led(LED1);
dsubotic 0:1cadcdcf4521 6
dsubotic 0:1cadcdcf4521 7 double delay = 0.5; // 500 ms
dsubotic 0:1cadcdcf4521 8
dsubotic 0:1cadcdcf4521 9 void pressed()
dsubotic 0:1cadcdcf4521 10 {
dsubotic 0:1cadcdcf4521 11 delay = 0.1; // 100 ms
dsubotic 0:1cadcdcf4521 12 }
dsubotic 0:1cadcdcf4521 13
dsubotic 0:1cadcdcf4521 14 void released()
dsubotic 0:1cadcdcf4521 15 {
dsubotic 0:1cadcdcf4521 16 delay = 0.5; // 500 ms
dsubotic 0:1cadcdcf4521 17 }
dsubotic 0:1cadcdcf4521 18
dsubotic 0:1cadcdcf4521 19 int main()
dsubotic 0:1cadcdcf4521 20 {
dsubotic 0:1cadcdcf4521 21 // Assign functions to button
dsubotic 0:1cadcdcf4521 22 button.fall(&pressed);
dsubotic 0:1cadcdcf4521 23 button.rise(&released);
dsubotic 0:1cadcdcf4521 24
dsubotic 0:1cadcdcf4521 25 while (1) {
dsubotic 0:1cadcdcf4521 26 led = !led;
dsubotic 0:1cadcdcf4521 27 wait(delay);
dsubotic 0:1cadcdcf4521 28 }
dsubotic 0:1cadcdcf4521 29 }