KRAI 2017
/
ESC_test
esc test kontrol atas
main.cpp@1:8b6c35986de0, 2016-09-26 (annotated)
- Committer:
- franshendri
- Date:
- Mon Sep 26 08:40:53 2016 +0000
- Revision:
- 1:8b6c35986de0
- Parent:
- 0:7388487b63fb
code terbaru buat ESC, udah dicoba dan siap pakai
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Najib_irvani | 0:7388487b63fb | 1 | #include "mbed.h" |
Najib_irvani | 0:7388487b63fb | 2 | #include "esc.h" |
Najib_irvani | 0:7388487b63fb | 3 | |
franshendri | 1:8b6c35986de0 | 4 | ESC edf(D9,20); |
Najib_irvani | 0:7388487b63fb | 5 | Serial pc(USBTX,USBRX); |
Najib_irvani | 0:7388487b63fb | 6 | |
franshendri | 1:8b6c35986de0 | 7 | float max = 0.3; |
franshendri | 1:8b6c35986de0 | 8 | float pwm = 0; |
Najib_irvani | 0:7388487b63fb | 9 | |
Najib_irvani | 0:7388487b63fb | 10 | int main() { |
Najib_irvani | 0:7388487b63fb | 11 | |
Najib_irvani | 0:7388487b63fb | 12 | pc.baud(9600); |
Najib_irvani | 0:7388487b63fb | 13 | edf.setThrottle(pwm); |
Najib_irvani | 0:7388487b63fb | 14 | edf.pulse(); |
franshendri | 1:8b6c35986de0 | 15 | wait_ms (5000); |
Najib_irvani | 0:7388487b63fb | 16 | |
Najib_irvani | 0:7388487b63fb | 17 | while(1) { |
franshendri | 1:8b6c35986de0 | 18 | |
franshendri | 1:8b6c35986de0 | 19 | if ( pwm < max){ |
franshendri | 1:8b6c35986de0 | 20 | pwm += 0.01; |
franshendri | 1:8b6c35986de0 | 21 | } |
franshendri | 1:8b6c35986de0 | 22 | else{ |
franshendri | 1:8b6c35986de0 | 23 | pwm = max; |
franshendri | 1:8b6c35986de0 | 24 | } |
franshendri | 1:8b6c35986de0 | 25 | |
Najib_irvani | 0:7388487b63fb | 26 | edf.setThrottle(pwm); |
Najib_irvani | 0:7388487b63fb | 27 | edf.pulse(); |
Najib_irvani | 0:7388487b63fb | 28 | wait_ms(70); |
Najib_irvani | 0:7388487b63fb | 29 | } |
Najib_irvani | 0:7388487b63fb | 30 | } |