|
Tài trợ cho PIC Vietnam |
|
Ðiều Chỉnh | Xếp Bài |
28-10-2014, 09:54 AM | #26 |
Đệ tử 3 túi
Tham gia ngày: Apr 2007
Bài gửi: 46
: |
Lập Trình Hiển Thị LCD 4bit Trên Vi Điều Khiển 8051
Chào các bạn, trong các bài trước mình chia sẽ các project cho vi điều khiển pic. Hôm nay, mình chia sẽ cùng các bạn project cho 8051, ở đây cũng lập trình bằng ngôn ngữ Mikroc, trình biên dịch Mikroc for 8051.
Sơ đồ nguyên lý của project như sau: Ở đây mình không giải thích nhiều, do sơ đồ nguyên lý rất đơn giản, trong code đã có các phần giải thích cho các dòng lệnh. CODE CHƯƠNG TRÌNH: /*Share by dientudieukhien.net MikroC Pro for Pic*/ // Lcd module connections sbit LCD_RS at P2_0_bit; sbit LCD_EN at P2_1_bit; sbit LCD_D4 at P2_2_bit; sbit LCD_D5 at P2_3_bit; sbit LCD_D6 at P2_4_bit; sbit LCD_D7 at P2_5_bit; // End Lcd module connections char txt1[] = "Embedded"; char txt2[] = "Projects"; char txt3[] = "Lcd 4 bit"; char txt4[] = "Tutorial"; char i; // Loop variable void Move_Delay() { // Function used for text moving Delay_ms(500); // You can change the moving speed here } void main(){ Lcd_Init(); // Initialize Lcd Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off Lcd_Out(1,6,txt3); // Write text in first row Lcd_Out(2,6,txt4); // Write text in second row Delay_ms(2000); Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Out(1,1,txt1); // Write text in first row Lcd_Out(2,5,txt2); // Write text in second row Delay_ms(2000); // Moving text for(i=0; i<4; i++) { // Move text to the right 4 times Lcd_Cmd(_LCD_SHIFT_RIGHT); Move_Delay(); } while(1) { // Endless loop for(i=0; i<8; i++) { // Move text to the left 7 times Lcd_Cmd(_LCD_SHIFT_LEFT); Move_Delay(); } for(i=0; i<8; i++) { // Move text to the right 7 times Lcd_Cmd(_LCD_SHIFT_RIGHT); Move_Delay(); } } } || Xem nguồn bài viết gốc tại: http://www.dientudieukhien.net/2014/...hien-8051.html
__________________
Projects for PIC, AVR in MikroC and C | Điện tử cơ bản | Mạch điện tử ứng dụng | Tài liệu điện tử | Tài liệu truyền hình | Ebook | Softwaves | tool online | Visit my site address: http://dientudieukhien.net/ |
Tags |
16f877a, 7 segment, lap trinh pic 16f887, mikroc for pic, pic with lcd |
|
|