Opzetje
Dependencies: mbed QEI HIDScope biquadFilter MODSERIAL FastPWM
Diff: motor.cpp
- Revision:
- 7:2f612f32711a
diff -r 3930811edddf -r 2f612f32711a motor.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/motor.cpp Tue Oct 01 14:45:37 2019 +0000 @@ -0,0 +1,32 @@ +#include "mbed.h" +#include "MODSERIAL.h" +#include "FastPWM.h" + +Serial pc(USBTX,USBRX); + +InterruptIn button1(PTC2); +InterruptIn button2(PTC3); +InterruptIn button3(PTA4); +InterruptIn button4(PTC6); + +AnalogIn pot(PTB2); + +//DigitalOut motor(D5); +FastPWM lampje(D3); +FastPWM motor(D5); +Ticker ticker; + + +void motor_speed() +{ + float f = pot.read(); + pc.printf("%f\n\r",f); + motor.write(f); + lampje.write(f); +} + +int main() +{ + ticker.attach(&motor_speed, 0.01f); + while(true){}; +} \ No newline at end of file