![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
test
Dependencies: MbedJSONValue DISCO_L475VG_IOT01A_wifi mbed-http
ServoMove.cpp@0:065178c282bd, 2019-01-01 (annotated)
- Committer:
- Eason0505
- Date:
- Tue Jan 01 11:48:52 2019 +0000
- Revision:
- 0:065178c282bd
test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Eason0505 | 0:065178c282bd | 1 | #include "ServoMove.h" |
Eason0505 | 0:065178c282bd | 2 | PwmOut servo(PA_6); |
Eason0505 | 0:065178c282bd | 3 | Serial pc1(USBTX, USBRX); |
Eason0505 | 0:065178c282bd | 4 | |
Eason0505 | 0:065178c282bd | 5 | void ServoConvert(double cnv) |
Eason0505 | 0:065178c282bd | 6 | { |
Eason0505 | 0:065178c282bd | 7 | if (cnv > 144) { |
Eason0505 | 0:065178c282bd | 8 | servo.pulsewidth_us(1000); //0deg |
Eason0505 | 0:065178c282bd | 9 | pc1.printf("cnv1 =%f\n\r",cnv); |
Eason0505 | 0:065178c282bd | 10 | } else if(cnv >108 && cnv <144) { |
Eason0505 | 0:065178c282bd | 11 | servo.pulsewidth_us(1100); |
Eason0505 | 0:065178c282bd | 12 | pc1.printf("cnv2 =%f\n\r",cnv); |
Eason0505 | 0:065178c282bd | 13 | } else if (cnv >72 && cnv <108) { |
Eason0505 | 0:065178c282bd | 14 | servo.pulsewidth_us(1200); |
Eason0505 | 0:065178c282bd | 15 | pc1.printf("cnv3 =%f\n\r",cnv); |
Eason0505 | 0:065178c282bd | 16 | } else if (cnv > 36&& cnv <72) { |
Eason0505 | 0:065178c282bd | 17 | servo.pulsewidth_us(1300); |
Eason0505 | 0:065178c282bd | 18 | pc1.printf("cnv4 =%f\n\r",cnv); |
Eason0505 | 0:065178c282bd | 19 | } else if(cnv > 0&& cnv <36) { |
Eason0505 | 0:065178c282bd | 20 | servo.pulsewidth_us(1400); |
Eason0505 | 0:065178c282bd | 21 | pc1.printf("cnv5 =%f\n\r",cnv); |
Eason0505 | 0:065178c282bd | 22 | } else if(cnv > -36&& cnv <0) { |
Eason0505 | 0:065178c282bd | 23 | servo.pulsewidth_us(1500); |
Eason0505 | 0:065178c282bd | 24 | pc1.printf("cnv6 =%f\n\r",cnv); |
Eason0505 | 0:065178c282bd | 25 | } else if(cnv > -72&& cnv <-36) { |
Eason0505 | 0:065178c282bd | 26 | servo.pulsewidth_us(1600); |
Eason0505 | 0:065178c282bd | 27 | pc1.printf("cnv7 =%f\n\r",cnv); |
Eason0505 | 0:065178c282bd | 28 | } else if(cnv > -108&& cnv <-72) { |
Eason0505 | 0:065178c282bd | 29 | servo.pulsewidth_us(1700); |
Eason0505 | 0:065178c282bd | 30 | pc1.printf("cnv8 =%f\n\r",cnv); |
Eason0505 | 0:065178c282bd | 31 | } else if(cnv > -144&& cnv <-108) { |
Eason0505 | 0:065178c282bd | 32 | servo.pulsewidth_us(1800); |
Eason0505 | 0:065178c282bd | 33 | pc1.printf("cnv9 =%f\n\r",cnv); |
Eason0505 | 0:065178c282bd | 34 | } else if(cnv > -180&& cnv <-144) { |
Eason0505 | 0:065178c282bd | 35 | servo.pulsewidth_us(1900); |
Eason0505 | 0:065178c282bd | 36 | pc1.printf("cnv10 =%f\n\r",cnv); |
Eason0505 | 0:065178c282bd | 37 | } |
Eason0505 | 0:065178c282bd | 38 | } |