Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: HIDScope MODSERIAL mbed
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