This version does not work on my pc however it should work if i look at all the data send to hidscope and de led which does it correct. We should tray another pc because my pc does give still some errors on the libaries
Dependencies: HIDScope MODSERIAL mbed
Fork of Milestone_1_Motor_DualDirection_potmeter_v2 by
Diff: main.cpp
- Revision:
- 0:9922b502cbc3
- Child:
- 1:aa505856416d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Sep 25 12:31:41 2018 +0000 @@ -0,0 +1,38 @@ +#include "mbed.h" +#include "MODSERIAL.h" +#include "HIDScope.h" + +PwmOut pwmpin(D6); +PwmOut led(D10); +AnalogIn potmeter(A5); +DigitalIn button(D2); +DigitalOut directionpin(D5); + +HIDScope scope(2); +Ticker ticker; + +volatile float x; +volatile float y; +volatile float x_prev; + +void sendData() { + scope.set(0,potmeter); //set the potmeter data to the first scope +// scope.set(1,x); + scope.send(); +} + +int main() { + float u = -0.3f; //determineusefulvalue, -0.3f is justanexample +// x = 1; + + pwmpin.period_us(60); //60 microsecondsPWM period, 16.7 kHz + led.period(0.00001); //10kHz + ticker.attach(&sendData, 0.001f); //send data to hidscope at 1kHz + directionpin= u > 0.0f; //eithertrueor false + + while (true) { + pwmpin.write(potmeter); //pwm of motor is potmeter value + led.write(potmeter); //led is potmeter value + wait(0.2f); + } +} \ No newline at end of file