mag niet van hendrik D:
Dependencies: mbed MatrixMath QEI HIDScope Matrix biquadFilter MODSERIAL FastPWM
Diff: main.cpp
- Revision:
- 14:20f11bb58244
- Parent:
- 9:12b9865e7373
- Child:
- 15:80b3ac2b8448
diff -r 12b9865e7373 -r 20f11bb58244 main.cpp --- a/main.cpp Thu Sep 19 14:41:31 2019 +0000 +++ b/main.cpp Mon Sep 23 08:17:52 2019 +0000 @@ -1,10 +1,16 @@ #include "mbed.h" +#include "FastPWM.h" + +// Motor 1 aan zetten en uit zetten dmv button 1 en 2 werkt. +// Snelheid aansturen nog niet. Serial pc(USBTX,USBRX); InterruptIn BUT1(D1); InterruptIn BUT2(D0); -PwmOut lichtje(D3); +FastPWM lichtje(D3); AnalogIn ain(A0); +DigitalOut direction(D6); +DigitalOut speed(D7); float getal; int n=5; @@ -12,6 +18,7 @@ void plus() { n++; // n=n+1 + direction = 1; if (n>10){ n=10; } @@ -20,6 +27,7 @@ void min() { n--; + direction = 0; if (n<0){ n=0; } @@ -32,10 +40,12 @@ BUT2.fall(min); while(true) { - getal = 0.01*n*ain.read(); - lichtje.period(4.0f); // 4 second period + getal = 0.1*n*ain.read(); + speed = 0.1*n*ain.read(); + lichtje.period_ms(20); // 4 second period lichtje.write(getal); // duty cycle - pc.printf("%3.3f%\n\r", ain.read()); + speed.write(getal); + pc.printf("%3.3f%\n\r", getal); } } \ No newline at end of file