Bayu Dharmaputra
/
Speed_Assignment
Speed Assignment Biorobotics
Diff: main.cpp
- Revision:
- 0:c4fba4d6195f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Sep 23 07:52:51 2015 +0000 @@ -0,0 +1,28 @@ +#include "mbed.h" +#include "encoder.h" +Serial pc(USBTX, USBRX); // tx, rx +Encoder motor1_pos(D13,D12); +DigitalOut motor1(D4); +PwmOut motorspeed1(D5); +PwmOut motorspeed2(D6); +DigitalOut motor2(D7); +const int on = 0; +const int off = 1; +const float frequency = 1000.0; + +int main() +{ + motorspeed2.period(1/frequency); + while (true) { + + for(float b=0.0f ; b<1.1f ; b+=0.1f) + { + motor2.write(on); + motorspeed2.write(b); + pc.printf("b is %f\n",b); + wait(1); + + } + + } +} \ No newline at end of file