Full application

Dependencies:   mbed libTCS34725 lib_LoRaWAN

Committer:
dsubotic
Date:
Wed Jan 16 13:19:41 2019 +0000
Revision:
1:c3a839871165
Parent:
0:1cadcdcf4521
Child:
2:7040e447d0df
Changed pin names to octa pin layout (Button and red LED)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dsubotic 0:1cadcdcf4521 1 #include "mbed.h"
dsubotic 0:1cadcdcf4521 2
dsubotic 1:c3a839871165 3 InterruptIn button(PG_0);
dsubotic 0:1cadcdcf4521 4
dsubotic 1:c3a839871165 5 DigitalOut led(PD_14);
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 }