用AVR单片机,异或操作产生不同频率的声音
#include<_iom88to328v.h> /*预处理命令*/
//#include
#define uchar unsigned char
#define uint unsigned int
void delay(uchar t)
{
uchar i,j;
for (i=0;i
}
void sound_pc0(uchar t)
{
uint i;
DDRC=0xff;
PORTC=0xff;
for (i=0;i<350-t*t;i++)
{
PORTC^=0x01;
delay(t);
}
}
void main (void)
{
uchar dt;
for(;;)
{
for(dt=1;dt<14;dt++)
sound_pc0(dt);
}
}
完整资料打包(含仿真):