Jan Boerman
/
BlinkingLED
homework 1 exercise 8
Diff: main.cpp
- Revision:
- 0:be2d3e8ac709
--- /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