Sulhan Fauzi
/
_Tugas_Hybrid_LCD_SulhanF
Bisa menampilkan nama , pembacaann adc, dan kondisi sensor
LCD_Sulhan.cpp
- Committer:
- Sufa
- Date:
- 2015-11-28
- Revision:
- 0:c3a8fe9645c5
File content as of revision 0:c3a8fe9645c5:
/*********************************************************************/ /** **/ /** PROGRAM TAMPIL LCD **/ /** **/ /** 28, Sabtu, 2015 **/ /** **/ /** Dibuat oleh : **/ /** Sulhan Fauzi **/ /** 13214101 **/ /** **/ /*********************************************************************/ #include "mbed.h" #include "TextLCD.h" /* Program ini akan menampilkan tampilan di LCD dengan pemilihan menu */ TextLCD lcd (D7, D6, D5, D4, D3, D2, TextLCD :: LCD20x4); //rs, e, d4-d7 DigitalIn butA (PA_12); DigitalIn butB (PA_11);; DigitalIn butC (PB_12); DigitalOut led (D13); DigitalOut SelA (D11); DigitalOut SelB (D12); DigitalOut SelC (D14); AnalogIn sensorkanan (A0); AnalogIn sensorkiri (A1); void Selektor (int output) { if (output == 0) { SelA = 0; SelB = 0; SelC = 0; } else if (output == 1) { SelA = 1; SelB = 0; SelC = 0; } else if (output == 3) { SelA = 0; SelB = 1; SelC = 0; } else if (output == 4) { SelA = 0; SelB = 0; SelC = 1; } else if (output == 5) { SelA = 1; SelB = 0; SelC = 1; } else if (output == 6) { SelA = 0; SelB = 1; SelC = 1; } else if (output == 7) { SelA = 1; SelB = 1; SelC = 1; } } char sensor_ki (int urutan) { char s; Selektor(urutan); wait_ms(1); if (sensorkiri.read() >= 1) { s='1'; } else { s='0'; } return s; } char sensor_ka (int urutan ) { char s; Selektor(urutan); wait_ms(1); if (sensorkanan.read() >= 1) { s='1'; } else { s='0'; } return s; } float adcsensorkiri (int urutan) { Selektor(urutan); wait_ms(10); return sensorkiri.read(); } float adcsensorkanan (int urutan) { Selektor(urutan); wait_ms(10); return sensorkiri.read(); } void tampil () { int i, j; i=2; j=1; while (1) { for (j==1; j++; j==7) { lcd.locate(i,3); lcd.putc(adcsensorkanan(j)); i = i + 1; } lcd.locate(8,3); for (j==1; j++; j==7) { lcd.locate(i,3); lcd.putc(adcsensorkiri(j)); i = i + 1; } } } void tampil_adc() { int k,j,i; i=0; while(i <= 3) { j=0; k=7; while(j<16 && k>3) { lcd.locate(j,i); if(i==0) { //lcd.locate(j,i); lcd.printf("%1.2f",adcsensorkiri(k)); } else if(i==1) { //lcd.locate(j,i); lcd.printf("%1.2f",adcsensorkiri(k-4)); } else if(i==2) { //lcd.locate(j,i); lcd.printf("%1.2f",adcsensorkanan(k)); } else if(i==3) { //lcd.locate(j,i); lcd.printf("%1.2f",adcsensorkanan(k-4)); } j=j+5; k--; } i++; } } int main () { int i; while (1) { if ((butA == 1) and (butB == 0) and (butC == 0)) { i = 0; while ( i < 5) { lcd.cls (); lcd.locate(5,0); lcd.printf(" Sulhan "); lcd.locate(4,1); lcd.printf(" 13214101 "); wait_ms(1000); lcd.cls(); wait_ms(1000); i = i + 1; } } else if ((butA == 0) and (butB == 1) and (butC == 0)) { lcd.cls(); lcd.locate(4,0); lcd.printf("Pembacaan ADC"); lcd.locate(4,1); wait_ms(1000); lcd.cls(); tampil_adc(); wait_ms(1000); } else if ((butA == 0) and (butB == 0) and (butC == 1)) { while (1) { led =1; wait_ms(200); led=0; wait_ms(200); tampil (); } } else { lcd.cls(); lcd.locate (0,0); lcd.printf (" Pilih menu "); lcd.locate (1,1); lcd.printf ("1. Nama"); lcd.locate (1,2); lcd.printf ("2. Pembacaan ADC"); lcd.locate (1,3); lcd.printf("3. LED dan Sensor"); wait_ms(1000); } } }