![](/media/cache/group/mehmet_akif_arvas.jpg.50x50_q85.jpg)
thread ve servo motor kullanimi
Dependencies: mbed servo_motor mbed-rtos
main.cpp@0:3221160b3d1f, 2019-12-17 (annotated)
- Committer:
- marvas
- Date:
- Tue Dec 17 12:55:58 2019 +0000
- Revision:
- 0:3221160b3d1f
thread ve servo motor kullanimi
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
marvas | 0:3221160b3d1f | 1 | #include "mbed.h" |
marvas | 0:3221160b3d1f | 2 | #include "rtos.h" |
marvas | 0:3221160b3d1f | 3 | #include "servo.h" |
marvas | 0:3221160b3d1f | 4 | Thread servo_calismasi; |
marvas | 0:3221160b3d1f | 5 | DigitalOut led(PA_5); |
marvas | 0:3221160b3d1f | 6 | servo motor(PC_8); |
marvas | 0:3221160b3d1f | 7 | |
marvas | 0:3221160b3d1f | 8 | void motor_calismasi() |
marvas | 0:3221160b3d1f | 9 | { |
marvas | 0:3221160b3d1f | 10 | while(1) |
marvas | 0:3221160b3d1f | 11 | { |
marvas | 0:3221160b3d1f | 12 | motor.derece(5); |
marvas | 0:3221160b3d1f | 13 | wait(1); |
marvas | 0:3221160b3d1f | 14 | motor.derece(90); |
marvas | 0:3221160b3d1f | 15 | wait(1); |
marvas | 0:3221160b3d1f | 16 | motor.derece(120); |
marvas | 0:3221160b3d1f | 17 | wait(1); |
marvas | 0:3221160b3d1f | 18 | motor.derece(150); |
marvas | 0:3221160b3d1f | 19 | wait(1); |
marvas | 0:3221160b3d1f | 20 | motor.derece(175); |
marvas | 0:3221160b3d1f | 21 | wait(1); |
marvas | 0:3221160b3d1f | 22 | } |
marvas | 0:3221160b3d1f | 23 | } |
marvas | 0:3221160b3d1f | 24 | |
marvas | 0:3221160b3d1f | 25 | int main() |
marvas | 0:3221160b3d1f | 26 | { |
marvas | 0:3221160b3d1f | 27 | servo_calismasi.start(motor_calismasi);//thread başlatma ve fonkisyona yönlendirme |
marvas | 0:3221160b3d1f | 28 | while(true) { |
marvas | 0:3221160b3d1f | 29 | led=!led; |
marvas | 0:3221160b3d1f | 30 | wait(1); |
marvas | 0:3221160b3d1f | 31 | |
marvas | 0:3221160b3d1f | 32 | } |
marvas | 0:3221160b3d1f | 33 | return 0; |
marvas | 0:3221160b3d1f | 34 | } |