minh co 1 doan cose sau nhung luc bat tay vao lam thi ko biet phai sua the nao cac ban giup minh voi
minh da thay count column row bang 1 so bat ky va thay character bang chu minh muon hien thi nhung ko dc
minh moun xuat hien chu T tren man lcd hi phia sua j trong cose cua minh dua ra
Code:
#ifndef __LCD_H__ #define __LCD_H__ #define Data_LCD P2 sbit RS_LCD = P3^7; sbit RW_LCD = P3^6; sbit EN_LCD = P1^7; sbit Data_LCD_7 = P2^7; /////////////////////////// void wait_lcd(); void init_lcd(); void clear_lcd(); void write_lcd(unsigned char character[14]); /////////////////////////// void movetoxy(unsigned char column, unsigned char row); void delay(unsigned char count); ////////////////////////////////////////////// // CHECKING THE BUSY STATUS OF THE LCD // ////////////////////////////////////////////// void wait_lcd() { while(1) { //LCD_Busy: RS_LCD = 0; // It's command RW_LCD = 1; // It's Read Command Data_LCD = 0xFF; // P2_x = 1 EN_LCD = 1; // Start LCD command if(Data_LCD_7==0) // If bit 7 low, LCD free break;//goto LCD_Busy1; } EN_LCD = 0; // Finish the command RW_LCD = 0; // Turn off RW for future commands } ////////////////////////////////////////// // INITIALIZING THE LCD // ////////////////////////////////////////// void init_lcd() { RS_LCD = 0; Data_LCD = 0x38; EN_LCD = 1; EN_LCD = 0; wait_lcd(); RS_LCD = 0; Data_LCD = 0x0C; // Inititalizing LCD without cursor EN_LCD = 1; EN_LCD = 0; wait_lcd(); RS_LCD = 0; Data_LCD = 0x06; EN_LCD = 1; EN_LCD = 0; wait_lcd(); } ////////////////////////////////////// // CLEARING THE DISPLAY // ////////////////////////////////////// void clear_lcd() { RS_LCD = 0; Data_LCD = 0x01; EN_LCD = 1; EN_LCD = 0; wait_lcd(); } ////////////////////////////////////////// // WRITING TEXT TO THE LCD // ////////////////////////////////////////// void write_lcd(unsigned char character[41]) { unsigned char i; for(i=0;i<41;i++) { if(character[i]=='@') break; RS_LCD = 1; Data_LCD = character[i]; EN_LCD = 1; EN_LCD = 0; wait_lcd(); } } ////////////////////////////////////////////// // Setting postition cursor // ////////////////////////////////////////////// void movetoxy(unsigned char column, unsigned char row) { unsigned char pos; switch(row) { case 1: { pos = 0x7F + column; RS_LCD = 0; Data_LCD = pos; EN_LCD = 1; EN_LCD = 0; wait_lcd(); break; } default: { pos = 0xBF + column; RS_LCD = 0; Data_LCD = pos; EN_LCD = 1; EN_LCD = 0; wait_lcd(); break; } } } //////////////////////////////////////// void delay(unsigned char count) { int i; for(i=0;i<count*10;i++) ; } //////////////////////////////////////// ///////////////// END ///////////////// #endif
minh da thay count column row bang 1 so bat ky va thay character bang chu minh muon hien thi nhung ko dc
minh moun xuat hien chu T tren man lcd hi phia sua j trong cose cua minh dua ra
Comment