Magang KRTMI
/
Control_16718235_Ricky
Maju
Revision 0:8dbe4dae1b4a, committed 2019-03-20
- Comitter:
- RickyLinarto
- Date:
- Wed Mar 20 16:58:56 2019 +0000
- Commit message:
- Maju
Changed in this revision
diff -r 000000000000 -r 8dbe4dae1b4a .hg_archival.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hg_archival.txt Wed Mar 20 16:58:56 2019 +0000 @@ -0,0 +1,7 @@ +repo: b58c759a6e8d6f210bc8a6cdb9f796b1284641db +node: b58c759a6e8d6f210bc8a6cdb9f796b1284641db +branch: default +latesttag: null +latesttagdistance: 1 +changessincelatesttag: 1 +
diff -r 000000000000 -r 8dbe4dae1b4a Motor.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Motor.lib Wed Mar 20 16:58:56 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/RickyLinarto/code/Motor/#96cfe658b0d5
diff -r 000000000000 -r 8dbe4dae1b4a main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Mar 20 16:58:56 2019 +0000 @@ -0,0 +1,2 @@ +#include "mbed.h" +
diff -r 000000000000 -r 8dbe4dae1b4a maju.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/maju.cpp Wed Mar 20 16:58:56 2019 +0000 @@ -0,0 +1,41 @@ +#include <iostream> +#include "m.bed" +#include "Motor.h" + +bool loop = true + +Motor::Motor(PinName pwm, PinName fwd, PinName rev): + _pwm(pwm), _fwd(fwd), _rev(rev) { + + // Set initial condition of PWM + _pwm.period(0.002); + _pwm = 0; + + // Initial condition of output enables + _fwd = 0; + _rev = 0; +} + +void Motor::speed(float speed) { + _fwd = (speed > (float)0.0); + _rev = (speed < (float)0.0); + _pwm = fabs(speed); +} + +void Motor::period(float period){ + + _pwm.period(period); + +} +int main () { + Motor MotorA (PC_7, PA_9, PA_8); + Motor MotorB (PA_7, PA_6, PA_5); + Motor MotorC (PB_3, PA_10, PA_2); + + while (loop == true) { + MotorA.speed (-0.5); + MotorB.speed (0.5); + } + + return 0; + } \ No newline at end of file
diff -r 000000000000 -r 8dbe4dae1b4a mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Mar 20 16:58:56 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file