❶ 银行一米线的c程序 芯片AT89C52,语音模块接单片机的P34,P35端口,激光模块接单片机的P24,P25端口,语言是

#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit rst=P3^;
sbit sda=P3^5;
uchar flag;
//sbit key=P2^0;
//sbit l1=P1^2;
//sbit l2 =P1^3;
//sbit fm=P1^7;
sbit j1=P3^2;
sbit j2=P3^3;
uchar flag1,flag2,flag3,flag4;
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void delayus(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=10;y>0;y--);
}
void send_oneline(uchar add)
{
uchar i;
rst=0;
delay(1);
rst=1;
delay(17); /*复位延时 17MS*/
rst=1;
delay(6); /* delay 6ms */
sda=0;
delay(5); /* delay 5ms */
for(i=0;i<8;i++)
{sda=1;
if(add & 1)
{delayus(4); /* 400us */
sda=0;
delayus(2); /* 200us */
}
else {
delayus(2); /* 200us */
sda=0;
delayus(4); /* 400us */
}
add>>=1; }
sda=1;

}
void main()
{
uchar num;
while(1)
{
if(j1==0)
{
flag=1;
num++;
while(!j1);
while(flag)
{
if(j2==0)
{
while(!j2);
if(num==1)
{
send_oneline(0);
delay(3000);
}
if(num>=2)
{
send_oneline(2);
delay(2500);
}
flag=0;
}
}
}
if(j2==0)
{
flag=1;
num--;
while(!j2);
while(flag)
{
if(j1==0)
{
while(!j1);
if(num==0)
{
num=0;
send_oneline(1);
delay(3000);
}
if(num>=1)
{
send_oneline(3);
delay(2500);
}
flag=0;
}
}
}
}
}