標(biāo)題:
單片機(jī)之間雙向通信Proteus仿真程序
[打印本頁]
作者:
dong12
時間:
2020-5-11 10:52
標(biāo)題:
單片機(jī)之間雙向通信Proteus仿真程序
51hei.png
(22.94 KB, 下載次數(shù): 58)
下載附件
2020-5-11 14:48 上傳
單片機(jī)源程序如下:
/*************** writer:shopping.w ******************/
#include <reg52.h>
#define uint unsigned int
#define uchar unsigned char
sbit LED1 = P1^0;
sbit LED2 = P1^3;
sbit K1 = P1^7;
uchar Operation_NO = 0;
uchar code DSY_CODE[]=
{
0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f
};
void Delay(uint x)
{
uchar i;
while(x--)
{
for(i=0;i<120;i++);
}
}
void putc_to_SerialPort(uchar c)
{
SBUF = c;
while(TI == 0);
TI = 0;
}
void main()
{
LED1=LED2=1;
P0 = 0x00;
SCON = 0x50;
TMOD = 0x20;
PCON = 0x00;
TH1 = 0xfd;
TL1 = 0xfd;
TI = 0;
RI = 0;
TR1 = 1;
IE = 0x90;
while(1)
{
Delay(100);
if(K1 == 0)
{
while(K1==0);
Operation_NO=(Operation_NO+1)%4;
switch(Operation_NO)
{
case 0:
putc_to_SerialPort('X');
LED1=LED2=1; break;
case 1:
putc_to_SerialPort('A');
LED1=0;LED2=1;break;
case 2:
putc_to_SerialPort('B');
LED2=0;LED1=1;break;
case 3:
putc_to_SerialPort('C');
LED1=0;LED2=0;break;
}
}
}
}
void Serial_INT() interrupt 4
{
if(RI)
{
RI = 0;
if(SBUF>=0&&SBUF<=9)
P0 = DSY_CODE[SBUF];
else
P0 = 0x00;
}
}
復(fù)制代碼
所有資料51hei提供下載:
單片機(jī)之間雙向通信.zip
(85.59 KB, 下載次數(shù): 22)
2020-5-11 10:52 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
作者:
dong12
時間:
2020-5-14 10:43
不錯的資料
作者:
xiaodong11
時間:
2020-5-14 11:01
加油,資料很好
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1