PID + multiple point

Dependencies:   Motor PS_PAD TextLCD mbed-os

Fork of cobaLCDJoyMotor_Thread by EL4121 Embedded System

Committer:
rizqicahyo
Date:
Sat Dec 09 10:20:20 2017 +0000
Revision:
3:a03ce2084ceb
Parent:
2:907766ac29a2
Child:
4:cd5de3b14797
tes library LCD dan joystick

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rizqicahyo 1:2bf3dac65b08 1
rizqicahyo 0:837acb06c892 2 #include "mbed.h"
rizqicahyo 0:837acb06c892 3 #include "TextLCD.h"
rizqicahyo 3:a03ce2084ceb 4 #include "PS_PAD.h"
rizqicahyo 3:a03ce2084ceb 5 #include "motordriver.h"
rizqicahyo 0:837acb06c892 6
rizqicahyo 3:a03ce2084ceb 7 #include <string>
rizqicahyo 3:a03ce2084ceb 8 using namespace std;
rizqicahyo 3:a03ce2084ceb 9
rizqicahyo 3:a03ce2084ceb 10
rizqicahyo 3:a03ce2084ceb 11 TextLCD lcd(PB_7, PA_15, PA_14, PB_8, PB_1, PA_13, TextLCD::LCD20x4); //rs,e,d4-d7
rizqicahyo 3:a03ce2084ceb 12
rizqicahyo 3:a03ce2084ceb 13 PS_PAD ps2(PB_15,PB_14,PB_13, PC_4); //(mosi, miso, sck, ss)
rizqicahyo 3:a03ce2084ceb 14
rizqicahyo 3:a03ce2084ceb 15 /* motor
rizqicahyo 3:a03ce2084ceb 16 Motor motor3(PA_8, PB_0, PC_15, 1); //motor1
rizqicahyo 3:a03ce2084ceb 17 Motor motor1(PA_11, PA_6, PA_5, 1); //motor2
rizqicahyo 3:a03ce2084ceb 18 Motor motor4(PA_9, PC_2, PC_3, 1); //motor_slider
rizqicahyo 3:a03ce2084ceb 19 Motor motor2(PA_10, PB_5, PB_4, 1); //motor_griper
rizqicahyo 3:a03ce2084ceb 20 */
rizqicahyo 3:a03ce2084ceb 21
rizqicahyo 0:837acb06c892 22
rizqicahyo 0:837acb06c892 23 Serial pc(USBTX,USBRX);
rizqicahyo 0:837acb06c892 24
rizqicahyo 0:837acb06c892 25 int main()
rizqicahyo 0:837acb06c892 26 {
rizqicahyo 0:837acb06c892 27 pc.baud(115200);
rizqicahyo 3:a03ce2084ceb 28 ps2.init();
rizqicahyo 3:a03ce2084ceb 29
rizqicahyo 3:a03ce2084ceb 30 string a;
rizqicahyo 0:837acb06c892 31 while (1)
rizqicahyo 0:837acb06c892 32 {
rizqicahyo 3:a03ce2084ceb 33 // baca input
rizqicahyo 3:a03ce2084ceb 34 ps2.poll();
rizqicahyo 3:a03ce2084ceb 35
rizqicahyo 3:a03ce2084ceb 36 if(ps2.read(PS_PAD::PAD_X)==1) a = "silang";
rizqicahyo 3:a03ce2084ceb 37 else if(ps2.read(PS_PAD::PAD_CIRCLE)==1) a = "lingkaran";
rizqicahyo 3:a03ce2084ceb 38 else if(ps2.read(PS_PAD::PAD_TRIANGLE)==1) a = "segitiga";
rizqicahyo 3:a03ce2084ceb 39 else if(ps2.read(PS_PAD::PAD_SQUARE)==1) a = "kotak";
rizqicahyo 3:a03ce2084ceb 40 else a = "NULL";
rizqicahyo 3:a03ce2084ceb 41
rizqicahyo 3:a03ce2084ceb 42
rizqicahyo 3:a03ce2084ceb 43 //tampilkan LCD
rizqicahyo 3:a03ce2084ceb 44 lcd.locate(0,0);
rizqicahyo 3:a03ce2084ceb 45 lcd.printf("input joystik :");
rizqicahyo 3:a03ce2084ceb 46 lcd.locate(0,1);
rizqicahyo 3:a03ce2084ceb 47 lcd.printf("%s",a);
rizqicahyo 0:837acb06c892 48
rizqicahyo 0:837acb06c892 49 wait_ms(10);
rizqicahyo 0:837acb06c892 50 lcd.cls();
rizqicahyo 0:837acb06c892 51 }
rizqicahyo 0:837acb06c892 52 }
rizqicahyo 0:837acb06c892 53