欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
單片機之間雙向通信,仿真,程序
[打印本頁]
作者:
aiu_開
時間:
2019-4-10 20:11
標題:
單片機之間雙向通信,仿真,程序
仿真圖如下:
捕獲.PNG
(56.01 KB, 下載次數: 75)
下載附件
單片機仿真
2019-4-10 20:06 上傳
程序代碼如下:
#include <reg52.h>
#define uint unsigned int
#define uchar unsigned char
sbit LED1 = P1^0;
sbit LED2 = P1^3;
sbit K1 = P1^7;
uchar NumX = 0x00;
void Delay(uint x)
{
uchar i;
while(x--)
{
for(i=0;i<120;i++);
}
}
void main()
{
LED1=LED2=1;
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);
NumX = NumX%10;
SBUF = NumX;
NumX = NumX+1;
while(TI == 0);
TI = 0;
}
}
}
void Serial_INT() interrupt 4
{
if(RI)
{
RI = 0;
switch(SBUF)
{
case 'X': LED1=1;LED2=1;break;
case 'A': LED1=0;LED2=1;break;
case 'B': LED2=0;LED1=1;break;
case 'C': LED1=0;LED2=0;
}
}
}
復制代碼
另一個單片機要的程序:
/*************** 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;
}
}
復制代碼
完整程序,仿真附件:
單片機與單片機串口通訊.rar
(61.27 KB, 下載次數: 15)
2019-4-10 20:10 上傳
點擊文件名下載附件
附件
下載積分: 黑幣 -5
作者:
w先生
時間:
2019-4-13 22:33
AT89C51的串口通信工作方式一c語言程序例子有么?
作者:
榆林上校
時間:
2019-5-11 12:43
初學100例里面的例子
作者:
榆林上校
時間:
2019-5-11 12:48
這樣得來的也可以發
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1