国产免费AV|泡泡玛特欧洲总部将设在伦敦|中文天堂网www新版资源在线|一本久道综合在线中文|国精产品一二三产区的使用方法|香蕉鱼在线观看|www.27eee
ELEOK
標題:
51單片機火災報警Proteus仿真程序 adc0808+1602顯示
[打印本頁]
作者:
coolice
時間:
2020-1-22 12:10
標題:
51單片機火災報警Proteus仿真程序 adc0808+1602顯示
用滑動變阻代替煙霧、溫度傳感器。采有adc0808雙通道,通過at89c52,lcd1602顯示。
仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)
1.png
(132.61 KB)
下載附件
2020-1-22 12:06 上傳
單片機源程序如下:
#include "reg52.h"
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
#define yushe_wendu 54
#define yushe_yanwu 23
uchar code Init1[]="SET:000 NOW:000";
uchar code Init2[]="SEY:000 NOW:000";
uchar code num[]="0123456789";
uchar temp;
unsigned char CHANNEL; //AD channel variable
sbit ST_ALE=P3^0; //START and ALE both connect to P3.0
sbit EOC=P3^1; //EOC connect to P3.1
sbit OE=P3^2; //OE conect to P3.2
sbit CLK=P3^3;
sbit lcdrs=P2^4;
sbit lcdrw=P2^5;
sbit lcden=P2^6;
sbit beep=P3^4;
sbit led=P3^5;
void delay(uint x)
{
uint i;
for(;x>0;x--)
for(i=5;i>0;i--);
}
void write_com(uchar com )
{
lcden = 0;
lcdrs = 0;//表示命令選擇
P1 = com;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void write_data(uchar date)
{
lcden = 0;
lcdrs = 1;//n.1 write into the data;
P1 = date;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
//1602初始化
void Init1602()
{
uchar i=0;
write_com(0x38);//屏幕初始化
write_com(0x0c);//打開顯示 無光標 無光標閃爍
write_com(0x06);//當讀或寫一個字符是指針后一一位
write_com(0x80);//設置位置
for(i=0;i<4;i++)
{
write_data(Init1[i]); //顯示數組1的數據
}
write_com(0x80+9);
for(i=9;i<13;i++)
{
write_data(Init1[i]); //顯示數組1的數據
}
write_com(0x80+0x40);//設置位置
for(i=0;i<4;i++)
{
write_data(Init2[i]); //顯示數組2的數據
}
write_com(0x80+0x40+9);
for(i=9;i<13;i++)
{
write_data(Init2[i]); //顯示數組2的數據
}
}
void display(uchar channel)
{
unsigned long temp;
unsigned int k=0,i=0;
temp=P0; //the temporary variable
if(channel==0)
{
write_com(0x80+4); //設置煙霧
write_data(0x30+yushe_wendu/100);
write_data(0x30+yushe_wendu%100/10);
write_data(0x30+yushe_wendu%10);
write_com(0x80+13); //時時煙霧
write_data(0x30+temp/100);
write_data(0x30+temp%100/10);
write_data(0x30+temp%10);
}
if(channel==1)
{
write_com(0x80+0x40+4); //設置煙霧
write_data(0x30+yushe_yanwu/100);
write_data(0x30+yushe_yanwu%100/10);
write_data(0x30+yushe_yanwu%10);
write_com(0x80+0x40+13); //時時煙霧
write_data(0x30+temp/100);
write_data(0x30+temp%100/10);
write_data(0x30+temp%10);
}
}
void main()
{
CHANNEL=0xF8; //AD channel 0
ST_ALE=0; //START and ALE default
OE=0; //OE default
TMOD=0x02; //T0 operate in mode 2
TH0=0xFF; //auto load value
TL0=0xFF; //default value
EA=1; //all interrupt enable
ET0=1; //T0 interrupt enable
TR0=1; //T0 run
beep=0;
led=0;
while(1)
{
P2=0x07&CHANNEL; //choose AD channel
ST_ALE=1; //lock the AD channel address
ST_ALE=0; //AD run
Init1602();
while(EOC==0); //wait until AD over
OE=1; //enable to transmit AD data
if(CHANNEL==0xF8)
{
display(0); //view the AD result and diaplay LED
}
if(CHANNEL==0xF9)
{
display(1); //view the AD result and diaplay LED
}
delay(50); //delay to prepare for next AD channel
OE=0; //forbit to transmit AD data
if(CHANNEL==0xF9)
CHANNEL=0xF7; //AD channel loop
CHANNEL++; //next AD channel
}
}
void T1_TIME() interrupt 1 using 0
{
CLK=~CLK; //CLK 500 kHz
}
復制代碼
火災報警兩路.zip
(301.94 KB, 售價: 1 E幣)
2020-1-22 12:09 上傳
點擊文件名下載附件
售價: 1 E幣
[記錄]
[
購買
]
作者:
duzailian
時間:
2024-6-11 20:37
謝謝分享
歡迎光臨 ELEOK (http://m.afoofa.cn/)
Powered by Discuz! X5.0