Kodingan untuk sistem atas. Silahkan di edit dan dibuat seoptimal mungkin
Dependencies: Motor Servo mbed-rtos mbed
Diff: lonch.cpp
- Revision:
- 0:0ae8cd6754d2
- Child:
- 1:9dbbdb321fce
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lonch.cpp Mon Oct 31 13:36:59 2016 +0000 @@ -0,0 +1,66 @@ +/* Made by SF101 */ +/* 29/10/2016 */ +/* KRAI 2017 */ +/* Control the Launcher... */ + +// Library +#include "Motor.h" +#include "mbed.h" +#include "Servo.h" +#include "rtos.h" + +//Deklarasi Fungsi yang digunakan +// Motor :: Fungsi -- Nama fungsi -- (pwm, forward, reverse) +// Motor :: Fungsi -- Nama fungsi -- (pwm, vcc, gnd) + +Motor motor1 (PA_8, PC_12, PB_7); +Motor motor2 (PA_9, PA_13, PC_13); +Motor motor3 (PA_10, PA_14, PC_14); +Motor motor4 (PA_11, PA_15, PC_15); + +Servo servo1 (PB_8); +Servo servo2 (PC_8); +Servo servo3 (PB_9); +Servo servo4 (PC_9); +Servo servo5 (PB_6); +Servo servo6 (PC_6); + + + +// Deklarasi Variabel Global & Konstanta +int i; +float sudut_awal = 80; +float sudut_min = 60; +float sudut_max = 90; + + +int main (void) { + + while (1) { + for ( i = 0 ; i >= 6 ; i++) // untuk melempar 7 saucer + { + servo1.position (sudut_ref); + wait_ms(100); + servo1.position (sudut_max); + wait_ms(100); + + motor1.speed(0.75); + motor2.speed(-0.75); + motor3.speed(0.25); + motor4.speed(-0.25); + motor5.speed(0.80); + motor6.speed(-0.80); + wait_ms(200); + motor1.brake(1); + motor2.brake(1); + motor3.brake(1); + motor4.brake(1); + motor5.brake(1); + motor6.speed(1); + wait_ms(100); + + servo1.position (sudut_min); + wait_ms(100); + } + } +} \ No newline at end of file