欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 3128|回復: 0
收起左側

LCD1602顯示單片機源碼

[復制鏈接]
ID:75262 發表于 2015-3-24 23:08 | 顯示全部樓層 |閱讀模式
這幾天精神狀態不佳,今天才出成果,LCD1602 顯示,由于使用的是字符型的LCD,所以無法顯示漢字,只能是字符,好了,代碼來襲~~
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit LCDE=P2^7;
sbit RS=P2^6;
sbit RW=P2^5;
uchar code table1[]="x=1,y=1";   //顯示第一行內容
uchar code table2[]="x=2,y=2";           //顯示第二行內容

void LCD_write_com(uchar com);          //寫指令
void LCD_write_dat(uchar dat);           //寫數據
void delay(uint z);
void init();


void LCD_write_com(uchar com)
{
RS=0;                  
P0=com;
delay(5);
LCDE=1;
delay(5);
LCDE=0;

}

void LCD_write_dat(uchar dat)
{
RS=1;
P0=dat;
delay(5);
LCDE=1;
delay(5);
LCDE=0;
}
void init()
{
RW=0;
LCD_write_com(0x38);         //數據總線8位,顯示2行,5*7點陣每字符
LCD_write_com(0x0c);         //顯示功能開,無光標
LCD_write_com(0x06);          //光標設置
LCD_write_com(0x80+0x10);  //數據指針位置
LCD_write_com(0x01);                   //清屏
}

void delay(uchar z)
{uint a,b;
for(a=z;a>0;a--)
for(b=110;b>0;b--);}

void main()
{uchar a;
init();
LCD_write_com(0x80);
for(a=0;a<7;a++)
{
LCD_write_dat(table1[a]);
delay(30);
}
LCD_write_com(0x80+0x40);
for(a=0;a<7;a++)
{LCD_write_dat(table2[a]);
delay(30);
}
delay(4500);
for(a=0;a<20;a++)
{
LCD_write_com(0x18);
delay(150);
}


}
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表