![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Boleh bisa langsung dicoba, tap servo base belum dikalibrasi
main.cpp@2:34ed8b55eba6, 2019-04-13 (annotated)
- Committer:
- harrymunli
- Date:
- Sat Apr 13 19:29:51 2019 +0000
- Revision:
- 2:34ed8b55eba6
- Parent:
- 1:9284c57e84da
- Child:
- 3:d1860dee0552
perubahan ke awal;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
harrymunli | 0:9dfae2e18414 | 1 | #include "mbed.h" |
harrymunli | 0:9dfae2e18414 | 2 | #include "Servo.h" |
harrymunli | 0:9dfae2e18414 | 3 | #include "Motor.h" |
harrymunli | 0:9dfae2e18414 | 4 | |
harrymunli | 0:9dfae2e18414 | 5 | /* Nama servo |
harrymunli | 0:9dfae2e18414 | 6 | 4 |
harrymunli | 0:9dfae2e18414 | 7 | 3 |
harrymunli | 0:9dfae2e18414 | 8 | 21 22 |
harrymunli | 0:9dfae2e18414 | 9 | 1 */ |
harrymunli | 0:9dfae2e18414 | 10 | |
harrymunli | 2:34ed8b55eba6 | 11 | Servo servo1(PA_7); |
harrymunli | 2:34ed8b55eba6 | 12 | Servo servo2(PB_6); |
harrymunli | 1:9284c57e84da | 13 | Serial pc(D1, D0); |
harrymunli | 0:9dfae2e18414 | 14 | |
harrymunli | 0:9dfae2e18414 | 15 | int main() { |
harrymunli | 1:9284c57e84da | 16 | pc.baud(9600); |
harrymunli | 1:9284c57e84da | 17 | pc.printf("test begin\n"); |
harrymunli | 0:9dfae2e18414 | 18 | |
harrymunli | 1:9284c57e84da | 19 | //tes |
harrymunli | 2:34ed8b55eba6 | 20 | servo1.calibrate(0.001,150); |
harrymunli | 2:34ed8b55eba6 | 21 | servo1.write(0); |
harrymunli | 2:34ed8b55eba6 | 22 | servo2.write(1.0); |
harrymunli | 1:9284c57e84da | 23 | while(1){ |
harrymunli | 2:34ed8b55eba6 | 24 | pc.printf("input (1..10) bakal dijadiin persen : "); |
harrymunli | 1:9284c57e84da | 25 | float n=0.0; |
harrymunli | 1:9284c57e84da | 26 | pc.scanf("%f",&n); |
harrymunli | 2:34ed8b55eba6 | 27 | pc.printf("\n"); |
harrymunli | 2:34ed8b55eba6 | 28 | //float f = (float)n/(float)10; |
harrymunli | 2:34ed8b55eba6 | 29 | servo1.write(f); |
harrymunli | 2:34ed8b55eba6 | 30 | pc.printf("%f", servo1.read()); |
harrymunli | 2:34ed8b55eba6 | 31 | pc.printf("\n"); |
harrymunli | 1:9284c57e84da | 32 | } |
harrymunli | 0:9dfae2e18414 | 33 | } |