#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
sbit csda=P2^2;
sbit wr=P2^1;
sbit s1=P3^2;
sbit s2=P3^3;
uchar k=0,p=0,delay=0;
uchar bxxz=0;
pinglv=0;
uchar a=1,b=0,c=0,d=0,e=0;
uchar code sin[64]={ 135,145,158,167,176,188,199,209,218,226,234,240,245,249,252,254,254,253,251,247,243,237,
230,222,213,204,193,182,170,158, 146,133,121,108,96,84,72,61,50,41,32,24,17,11,7,3,1,0,0,2,5,9,14,20,28,36,45,
55,66,78,90,102,114,128 };
uchar code juxing[64]={ 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255, 255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
void delay1()
{
int a,b;
for(a=1;a>0;a--)
for(b=122;b>0;b--);
}
void int0() interrupt 0
{
EX0=0; delay1(); if(s1==0)
{
bxxz++; if(bxxz==5) bxxz=0; switch(bxxz)
{
case 0 : {a=1,b=0,c=0,d=0,e=0;} break;
case 1 : {a=0,b=1,c=0,d=0,e=0;} break;
}
delay1();
while(!s1);
}
while(!s1);
EX0=1;
}
void int1() interrupt 2
{
EX1=0;
delay1();
if(s2==0)
{
p++;
if(p==8)
p=0;
switch(p)
{
case 1 : pinglv=3; break;
case 2 : pinglv=6; break;
case 3 :pinglv=9; break;
case 4 : pinglv=12;break;
case 5 : pinglv=15;break;
case 6 : pinglv=18;break;
case 7 : pinglv=21;break;
default :pinglv=0; break;
}
delay1();
while(!s2);
}
while(!s2);
EX1=1;
}
void main()
{
csda=0;
wr=0;
EA=1;
IT0=1;
EX0=1;
IT1=1;
EX1=1;
while(1)
{
while(a)
{
delay=pinglv;
P0=sin[k];
k++;
if(k==64)
k=0;
while(delay)
delay--;
}
while(b)
{
delay=pinglv;
P0=juxing[k];
k++;
if(k==64)
k=0;
while(delay)
delay--;
}
}
}
|