kodingan full omni 3roda embedded
Dependencies: Motor PS_PAD TextLCD mbed-os
Fork of odometry_omni_3roda_v3 by
Diff: main.cpp
- Revision:
- 3:a03ce2084ceb
- Parent:
- 2:907766ac29a2
- Child:
- 4:cd5de3b14797
--- a/main.cpp Sat Dec 09 09:52:26 2017 +0000 +++ b/main.cpp Sat Dec 09 10:20:20 2017 +0000 @@ -1,33 +1,50 @@ -/*********************************************************************/ -/** **/ -/** PROGRAM TAMPIL LCD **/ -/** **/ -/** 24 November, Selasa, 2015 **/ -/** **/ -/** Dibuat oleh : **/ -/** Rizqi Cahyo Yuwono **/ -/** 13214090 **/ -/** **/ -/*********************************************************************/ #include "mbed.h" #include "TextLCD.h" +#include "PS_PAD.h" +#include "motordriver.h" -TextLCD lcd(PB_7, PA_15, PA_14, PB_8, PB_1, PA_13, TextLCD::LCD20x4); //rs,e,d4-d7, +#include <string> +using namespace std; + + +TextLCD lcd(PB_7, PA_15, PA_14, PB_8, PB_1, PA_13, TextLCD::LCD20x4); //rs,e,d4-d7 + +PS_PAD ps2(PB_15,PB_14,PB_13, PC_4); //(mosi, miso, sck, ss) + +/* motor + Motor motor3(PA_8, PB_0, PC_15, 1); //motor1 + Motor motor1(PA_11, PA_6, PA_5, 1); //motor2 + Motor motor4(PA_9, PC_2, PC_3, 1); //motor_slider + Motor motor2(PA_10, PB_5, PB_4, 1); //motor_griper +*/ + Serial pc(USBTX,USBRX); int main() { pc.baud(115200); - //pc.printf("Pembacaan ADC Sensor : \n"); + ps2.init(); + + string a; while (1) { - - lcd.locate(0,0); - lcd.printf("rizqi cahyo Yuwono"); - lcd.locate(0,1); - lcd.printf("12314090"); + // baca input + ps2.poll(); + + if(ps2.read(PS_PAD::PAD_X)==1) a = "silang"; + else if(ps2.read(PS_PAD::PAD_CIRCLE)==1) a = "lingkaran"; + else if(ps2.read(PS_PAD::PAD_TRIANGLE)==1) a = "segitiga"; + else if(ps2.read(PS_PAD::PAD_SQUARE)==1) a = "kotak"; + else a = "NULL"; + + + //tampilkan LCD + lcd.locate(0,0); + lcd.printf("input joystik :"); + lcd.locate(0,1); + lcd.printf("%s",a); wait_ms(10); lcd.cls();