mag niet van hendrik D:
Dependencies: mbed MatrixMath QEI HIDScope Matrix biquadFilter MODSERIAL FastPWM
Diff: main.cpp
- Revision:
- 9:12b9865e7373
- Parent:
- 8:d1794f225fff
- Child:
- 10:3a3d6373b41c
- Child:
- 14:20f11bb58244
diff -r d1794f225fff -r 12b9865e7373 main.cpp --- a/main.cpp Sat Sep 14 11:08:13 2019 +0000 +++ b/main.cpp Thu Sep 19 14:41:31 2019 +0000 @@ -1,30 +1,41 @@ -#include "mbed.h" -#include "MODSERIAL.h" -#include "Callback.h" +#include "mbed.h" + +Serial pc(USBTX,USBRX); +InterruptIn BUT1(D1); +InterruptIn BUT2(D0); +PwmOut lichtje(D3); +AnalogIn ain(A0); -MODSERIAL pc(USBTX, USBRX); -DigitalOut ledr(LED_RED); -InterruptIn sw2(SW2); +float getal; +int n=5; -int n = 0; - -void flash() +void plus() +{ + n++; // n=n+1 + if (n>10){ + n=10; + } + } + +void min() { - 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); + n--; + if (n<0){ + n=0; + } } -} -int main() -{ +int main() { pc.baud(115200); - ledr = 1; - sw2.fall(flash); - while(1) { - } + lichtje=1; + BUT1.fall(plus); + BUT2.fall(min); + while(true) + { + getal = 0.01*n*ain.read(); + lichtje.period(4.0f); // 4 second period + lichtje.write(getal); // duty cycle + pc.printf("%3.3f%\n\r", ain.read()); + + } } \ No newline at end of file