iris
Dependencies: FastPWM HIDScope mbed
Revision 0:5746f50d8ee4, committed 2018-09-27
- Comitter:
- ekiliptiay
- Date:
- Thu Sep 27 08:37:30 2018 +0000
- Commit message:
- hey;
Changed in this revision
diff -r 000000000000 -r 5746f50d8ee4 FastPWM.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FastPWM.lib Thu Sep 27 08:37:30 2018 +0000 @@ -0,0 +1,1 @@ +http://os.mbed.com/users/Sissors/code/FastPWM/#c0b2265cff9c
diff -r 000000000000 -r 5746f50d8ee4 HIDScope.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HIDScope.lib Thu Sep 27 08:37:30 2018 +0000 @@ -0,0 +1,1 @@ +http://os.mbed.com/users/tomlankhorst/code/HIDScope/#d23c6edecc49
diff -r 000000000000 -r 5746f50d8ee4 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Sep 27 08:37:30 2018 +0000 @@ -0,0 +1,28 @@ +#include "mbed.h" +#include "HIDScope.h" + +// Motor 1 has PWM-pin D5 and direction-pin D4 + +AnalogIn pot1(A0); +DigitalOut directionpin(D4); +PwmOut pwmpin(D5); +HIDScope scope(1); // We’re going to send 1 channel of data +Ticker AInTicker; + +void ReadAnalogInAndFilter() +{ + float u = 2.0f*pot1-1.0f; + scope.set(0, u); // Brightness is saved in the first scope. + scope.send(); // send what's in scope memory to PC +} + +int main(){ + pwmpin.period_us(60); + AInTicker.attach(&ReadAnalogInAndFilter, 0.01f); + while (true) { + float u = 2.0f*pot1-1.0f; //determine useful value, -0.3f is just an example + directionpin = u > 0.0f; //either true or false + pwmpin.write = fabs(u); //pwm duty cycle can only be positive, floating point absolute value + wait(0.001f); + } +} \ No newline at end of file
diff -r 000000000000 -r 5746f50d8ee4 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Sep 27 08:37:30 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/97feb9bacc10 \ No newline at end of file