wosiyabo 发表于 2017-3-3 16:46 谢谢!!!!! |
|
#include<reg51.h> #define uchar unsigned char #define uint unsigned int #define led P1; sbit voice=P2^4; uchar tab1[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f}; uchar tab2[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe}; uchar tab3[]={0xe7,0xdb,0xbd,0x7e}; uchar tab4[]={0x7e,0xbd,0xdb,0xe7}; uchar he[4] = {0,0,0,0}; uchar num=0; uchar counter=0; uchar counter1=0; bit flag=0; bit flag1=0; void delay1m(uint x) { uint i,j; for(i=0;i<x;i++) for(j=0;j<120;j++); } void time0_time1_init() { TMOD=0x11; TH1=(65535-50000)/256; TL1=(65535-50000)%256; TH0=(65535-50000)/256; TL0=(65535-50000)%256; TR0=0; ET1=ET0=TR1=EA=1; } void main() { time0_time1_init(); delay1m(2000); while(1) { if(!flag1) { if(!voice) { num++;flag1=1; //e[0]=he[1]=he[2]=he[3]=0; if(num>=5){num=0;} TR0=1; } } } } |
| #define unsigned char uchar;这样吧 |