Jan Boerman
/
BlinkingLED
homework 1 exercise 8
Revision 0:be2d3e8ac709, committed 2016-09-12
- Comitter:
- Jankoekenpan
- Date:
- Mon Sep 12 16:50:33 2016 +0000
- Commit message:
- implemented excercise 8
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r be2d3e8ac709 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Sep 12 16:50:33 2016 +0000 @@ -0,0 +1,34 @@ +#include "mbed.h" + +DigitalOut led(LED_RED); +InterruptIn button(SW2); +Serial pc(USBTX, USBRX, "YOLO"); + +volatile int count = 1; + +void flash(DigitalOut out) { + out.write(false); + wait(0.2f); + out.write(true); + wait(0.5f); +} + +void onPress() { + pc.printf("Number of flashes: %d\r\n", count); + for (int i = 0; i < count; i++) { + flash(led); + } + count++; +} + +int main() +{ + led.write(true); + + pc.baud(115200); + pc.printf("Hello World!\r\n"); + + button.fall(&onPress); + + while (true); +} \ No newline at end of file
diff -r 000000000000 -r be2d3e8ac709 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Sep 12 16:50:33 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/2e9cc70d1897 \ No newline at end of file