📄 diantiti.txt
字号:
#include <regx52.h>
#include <absacc.h>
#define DAC1 XBYTE[0XBFFF]//Choose the DAC1
#define DAC2 XBYTE[0X7FFF]//Choose the DAC2
#define uchar unsigned char
#define uint unsigned int
uchar floor[5]={0,0,0,0,0};//the floor flag
bit up_down=1;//the direction of the elevator
//parameter for timing 20S
bit time_flag=1;
uchar t1_ms=0,t1_s=0;
uint led[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
void
initIO (void)//I/O initial
{
//T1 initial (wait 20S)
ET1=1;//open the T1 interrupt
TMOD=0x10;//set as autoreload 8-bit
TH1=0X3C;
TL1=0XB0;//65536-15536=50000
EA=1;//open the CPU interrupt
DAC2=0X00;
DAC1=0X00;
}
void
initTime(uchar tmp)
{
t1_ms=40;
t1_s=tmp;
TH1=0X3C;
TL1=0XB0;//65536-15536=50000
time_flag=1;
TR1=1;
}
uchar test_up(void)//test(from down to up) which floor have guy waited
{
}
uchar test_down(void)//test(from up to down) which floor have guy waited
{
}
bit test_key(void)//test which floor has guy
{
}
void go_where( uchar i )
{
}
uchar test_reach(void)//test reach which floor by the sensor
{
}
void
initState(void)
{
uchar tmp;
while ( test_key() )//wait until someone press the key
{
if (P2_0==0) tmp=0;
if (P2_1==0) tmp=1;
if (P2_2==0) tmp=2;
if (P2_3==0) tmp=3;
if (P2_4==0) tmp=4;
}
go_where(tmp);
}
void wait_ask( uchar toFloor)
{
}
void timer1() interrupt 3
{
t1_ms--;
TH1=0X3C;
TL1=0XB0;//65536-15536=50000
if (t1_ms==0)
{
t1_ms=40;
t1_s--;
if (t1_s==0)
{
TR1=0;
time_flag=0;
}
}
}
int
main(void)
{
uchar m;
initIO();
initState();
do
{
test_key(); //test someone press the key or not
m=test_reach();//test reach which floor by the sensor
if( m < 5)
{
wait_ask(m);
go_where(m);
}
}while(1);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -