DC Motor

Dependencies:   Motor mbed

Committer:
m211656
Date:
Mon Oct 01 18:53:40 2018 +0000
Revision:
0:0ca8b8fe09f6
DC Motor

Who changed what in which revision?

UserRevisionLine numberNew contents of line
m211656 0:0ca8b8fe09f6 1 #include "mbed.h"
m211656 0:0ca8b8fe09f6 2 #include "Motor.h"
m211656 0:0ca8b8fe09f6 3
m211656 0:0ca8b8fe09f6 4 Motor m(p26,p29,p30);
m211656 0:0ca8b8fe09f6 5 int main()
m211656 0:0ca8b8fe09f6 6 {
m211656 0:0ca8b8fe09f6 7 float f;
m211656 0:0ca8b8fe09f6 8 for(f=.2; f<1; f+=.2) {
m211656 0:0ca8b8fe09f6 9 m.speed(f);
m211656 0:0ca8b8fe09f6 10 printf("speed is %f \n\r", f);
m211656 0:0ca8b8fe09f6 11 getchar();
m211656 0:0ca8b8fe09f6 12 m.speed(-f);
m211656 0:0ca8b8fe09f6 13 printf("speed is - %f \n\r", f);
m211656 0:0ca8b8fe09f6 14 if(f==.8) {
m211656 0:0ca8b8fe09f6 15 break;
m211656 0:0ca8b8fe09f6 16 }
m211656 0:0ca8b8fe09f6 17 getchar();
m211656 0:0ca8b8fe09f6 18 }
m211656 0:0ca8b8fe09f6 19 while(1) {
m211656 0:0ca8b8fe09f6 20 getchar();
m211656 0:0ca8b8fe09f6 21 m.speed(1);
m211656 0:0ca8b8fe09f6 22 printf("speed is 1 \n\r");
m211656 0:0ca8b8fe09f6 23 getchar();
m211656 0:0ca8b8fe09f6 24 m.speed(-1);
m211656 0:0ca8b8fe09f6 25 printf("speed is -1 \n\r");
m211656 0:0ca8b8fe09f6 26 }
m211656 0:0ca8b8fe09f6 27 }