tes library LCD 20x4

Dependencies:   TextLCD mbed Motordriver PS_PAD

Fork of _Tugas_Hybrid_LCD_RizqiCahyoY by KRAI 2016

main.cpp

Committer:
rizqicahyo
Date:
2017-12-09
Revision:
3:a03ce2084ceb
Parent:
2:907766ac29a2
Child:
4:cd5de3b14797

File content as of revision 3:a03ce2084ceb:


#include "mbed.h"
#include "TextLCD.h"
#include "PS_PAD.h"
#include "motordriver.h"

#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);
    ps2.init();
    
    string a;
    while (1)
    {      
        // 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();
    }
}