fancy lampje

Dependencies:   mbed QEI HIDScope biquadFilter MODSERIAL FXOS8700Q FastPWM

Committer:
MatthewMaat
Date:
Thu Oct 03 15:08:32 2019 +0000
Revision:
12:7f280a661e71
Parent:
11:de4a85703169
Child:
13:ec4708dab45d
Control motor via potmeter

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RobertoO 0:67c50348f842 1 #include "mbed.h"
MatthewMaat 11:de4a85703169 2 //#include "HIDScope.h"
MatthewMaat 11:de4a85703169 3 //#include "QEI.h"
RobertoO 1:b862262a9d14 4 #include "MODSERIAL.h"
RobertoO 0:67c50348f842 5 //#include "BiQuad.h"
MatthewMaat 8:ec3c634390c7 6 #include "FastPWM.h"
MatthewMaat 2:626688c21b6f 7 #include <iostream>
MatthewMaat 5:cee5f898b350 8 MODSERIAL pc(USBTX, USBRX);
MatthewMaat 10:e1eb73e19540 9 AnalogIn ain(A0);
MatthewMaat 12:7f280a661e71 10 DigitalOut dir(D4);
MatthewMaat 12:7f280a661e71 11 //DigitalOut pwm(D5);
MatthewMaat 11:de4a85703169 12
MatthewMaat 11:de4a85703169 13
MatthewMaat 12:7f280a661e71 14 Ticker ticktick;
MatthewMaat 12:7f280a661e71 15 PwmOut motor1_pwm(D5);
MatthewMaat 10:e1eb73e19540 16
MatthewMaat 12:7f280a661e71 17 void setPWM(void)
MatthewMaat 11:de4a85703169 18 {
MatthewMaat 12:7f280a661e71 19 float rd=ain.read();
MatthewMaat 12:7f280a661e71 20 motor1_pwm.write(rd);
MatthewMaat 11:de4a85703169 21 }
MatthewMaat 11:de4a85703169 22
MatthewMaat 8:ec3c634390c7 23 int main()
MatthewMaat 4:f988679bf9a1 24 {
MatthewMaat 12:7f280a661e71 25 ticktick.attach(setPWM,0.1);
MatthewMaat 12:7f280a661e71 26 int frequency_pwm=10000;
MatthewMaat 12:7f280a661e71 27 motor1_pwm.period(1.0/frequency_pwm);
MatthewMaat 12:7f280a661e71 28 pc.printf("Starting...");
MatthewMaat 11:de4a85703169 29
MatthewMaat 8:ec3c634390c7 30 while (true) {
MatthewMaat 12:7f280a661e71 31 wait(10);
MatthewMaat 4:f988679bf9a1 32 }
MatthewMaat 4:f988679bf9a1 33 }