|
51單片機(jī),;LCD1602,最簡(jiǎn)單的顯示操作,適合新手入門學(xué)習(xí).
附有:PROTEUS文件,KEIL C語(yǔ)言源代碼,自己親手制作,親測(cè)可用.
- #include<reg52.h> //包含頭文件,一般情況不需要改動(dòng),頭文件包含特殊功能寄存器的定義
- #include <intrins.h> //包含NOP空指令函數(shù)_nop_
- #include<stdio.h>
- #define uchar unsigned char
- #define uint unsigned int
- sbit lcden=P3^4;
- sbit lcdrs=P3^5;
- void delayms(uint x)
- {
- uint i,j;
- for(i=x;i>0;i--)
- for(j=110;j>0;j--);
- }
- void write_com(uchar com)
- {
- lcdrs=0;//對(duì)RS寫0,從而選擇寫信信命令格式
- P0=com;
- delayms(5);
- lcden=1;
- delayms(5);
- lcden=0;
- }
- void write_data(uchar date)
- {
- lcdrs=1;
- P0=date;
- delayms(5);
- lcden=1;
- delayms(5);
- lcden=0;
- }
- void init()
- {
- lcden=0; //為寫數(shù)據(jù)到總線后 ,要給個(gè)高電平與使能端送數(shù)據(jù),先把電平拉低
- /* 對(duì)1602的格式進(jìn)行提前設(shè)置 ,用4句話 */
- write_com(0x38);//顯示模式設(shè)置,16X2顯示,5X7點(diǎn)陣,8位數(shù)據(jù)接口
- write_com(0x0c);
- write_com(0x06);
- write_com(0x01);
- }
- void main()
- {
- init();
-
- while(1) //進(jìn)了了啟動(dòng)AD從崦他們是隨時(shí)在后臺(tái)等待有A信號(hào)進(jìn)入,然后將其攔截
- {
-
- write_com(0x80+0x40+8);
- write_data('5');
-
- }
- }
復(fù)制代碼
|
-
-
1602最簡(jiǎn)單的顯示.zip
2016-8-15 13:58 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
72.77 KB, 下載次數(shù): 249, 下載積分: 黑幣 -5
評(píng)分
-
查看全部評(píng)分
|