|
本帖最后由 leizhihao13 于 2019-6-21 22:36 編輯
電路圖比較簡單,只用到了單片機最小系統的復位電路和晶振電路,然后接上排阻和1602液晶屏就OK了!自己畫圖,PCB圖,有點不夠完美是用到了一條飛線
部分代碼:
#include <reg51.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
uchar KeyCount=0;
sbit S2 = P3^0;
sbit S3 = P3^1;
uchar code cdis1[ ] = {" STOPWATCH 0 "};
uchar code cdis2[ ] = {" WYU-2864 "};
uchar code cdis3[ ] = {"TIME "};
uchar code cdis4[ ] = {" BEGIN COUNT 1 "};
uchar code cdis5[ ] = {" PAUSE COUNT 2 "};
uchar code cdis6[ ] = {" BEGIN COUNT 3 "};
uchar code cdis7[ ] = {" PAUSE COUNT 4 "};
uchar code cdis8[ ] = {" "};
sbit LCD_RS = P3^5;
sbit LCD_RW = P3^6;
sbit LCD_EN = P3^4;
sbit dula=P2^6;
sbit wela=P2^7;
#define delayNOP(); {_nop_();_nop_();_nop_();_nop_();};
uchar display[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00};
uchar display2[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
/*********************************************************
延時函數
*********************************************************/
void Delay(uint num)//延時函數
{
while( --num );
}
/*********************************************************
延時函數1
*********************************************************/
void delay1(int ms)
{
unsigned char n;
while(ms--)
{
for(n = 0; n<250; n++)
{
_nop_();
_nop_();
_nop_();
_nop_();
}
}
}
/**********************************************************
* *
*寫指令數據到LCD *
*RS=L,RW=L,E=高脈沖,D0-D7=指令碼。 *
* *
**********************************************************/
void lcd_wcmd(uchar cmd)
{
// while(lcd_busy());
LCD_RS = 0;
// LCD_RW = 0;
LCD_EN = 0;
_nop_();
_nop_();
P0 = cmd;
delayNOP();
LCD_EN = 1;
delayNOP();
LCD_EN = 0;
Delay(10);
}
/**********************************************************
* *
*寫顯示數據到LCD *
*RS=H,RW=L,E=高脈沖,D0-D7=數據。 *
* *
**********************************************************/
void lcd_wdat(uchar dat)
{
// while(lcd_busy());
LCD_RS = 1;
// LCD_RW = 0;
LCD_EN = 0;
P0 = dat;
delayNOP();
LCD_EN = 1;
delayNOP();
LCD_EN = 0;
Delay(10);
}
/**********************************************************
* *
* LCD初始化設定 *
* *
**********************************************************/
void lcd_init()
{
LCD_RW = 0;
dula=0;
wela=0;
delay1(15);
lcd_wcmd(0x01); //清除LCD的顯示內容
lcd_wcmd(0x38); //16*2顯示,5*7點陣,8位數據
delay1(5);
lcd_wcmd(0x38);
delay1(5);
lcd_wcmd(0x38);
delay1(5);
lcd_wcmd(0x0c); //開顯示,不顯示光標
delay1(5);
lcd_wcmd(0x01); //清除LCD的顯示內容
delay1(5);
}
|
-
-
原理圖、PCB圖、完整代碼.zip
2019-6-21 22:35 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
1.05 MB, 下載次數: 57, 下載積分: 黑幣 -5
里面含有原理圖、PCB圖和完整的C語言代碼
評分
-
查看全部評分
|