用89S51單片機(jī)P1^0出1KHZ和500HZ的音頻信號
#include
#define uchar unsigned char
sbit K =P1^7;
sbit out =P1^0;
void main ( )
{while ( 1)
{if (K ==0)
uchar i ;
for (i =200;i >0;i --)
{m _500HZ ( );
}
for (i =200;i >0;i --)
{m _1KHZ ( );
}
}
}
}
void m _500HZ ( )
{out =~out
delay (2);
}
void m _1KHZ ( )
{out =~out
delay (1)
}
void delay (uchar z )
{uchar x ;
uchar y ;
for (x =z;x >0;x --)
{for (y =55;y >0;y --)
}
}
評論