mag niet van hendrik D:
Dependencies: mbed MatrixMath QEI HIDScope Matrix biquadFilter MODSERIAL FastPWM
Revision 8:d1794f225fff, committed 2019-09-14
- Comitter:
- Hendrikvg
- Date:
- Sat Sep 14 11:08:13 2019 +0000
- Parent:
- 7:d307e31f7391
- Child:
- 9:12b9865e7373
- Commit message:
- Assignment 5: Works, except for notifying the user it only prints the first few characters of the string, then executes the flashes and then prints the remaining characters of the string.
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sat Sep 14 10:09:53 2019 +0000 +++ b/main.cpp Sat Sep 14 11:08:13 2019 +0000 @@ -1,36 +1,30 @@ #include "mbed.h" #include "MODSERIAL.h" +#include "Callback.h" MODSERIAL pc(USBTX, USBRX); DigitalOut ledr(LED_RED); +InterruptIn sw2(SW2); -class Counter -{ -public: - Counter(PinName pin) : _interrupt(pin) // create the InterruptIn on the pin specified to Counter - { - _interrupt.rise(callback(this, &Counter::increment)); // attach increment function of this counter instance - } +int n = 0; - void increment() - { - _count++; +void flash() +{ + n++; + pc.printf("The LED is now going to flash %i times.\n\r",n); + for (int i = 0; i < n; i++) { + ledr = 0; + wait_ms(50); + ledr = 1; + wait_ms(200); } - - int read() - { - return _count; - } -}; - -Counter counter(SW2); +} int main() { pc.baud(115200); + ledr = 1; + sw2.fall(flash); while(1) { - if _ - printf("Count so far: %d\n\r", counter.read()); - wait(2); } } \ No newline at end of file