这个图我改了一下 : 在接收线圈的整流电路 我用的是全桥整流,因为我用半波整流驱动不起来,损耗太大。还有就是电机要串上调压电阻。以便不用改变程序的移位速度。还有最好用贴片 减轻其重量。
程序:
#include <AT89X52.h>
#define uchar unsigned char
#define uint unsigned int //宏定义
sbit KEY=P3^2;
sbit led1=P1^1;
unsigned char code love[] = {
0xBF,0xFB,0xBB,0xFB,0xAB,0xFD,0xAB,0xFE,0x2B,0x01,0xAB,0x6D,0x8B,0x6D,0xA0,0x6D,0xAB,0x6D,0xAB,0x6D,0x2B,0x01,0xAB,0xFE,0xAB,0xFD,0xBB,0xFB,0xBF,0xFB,0xFF,0xFF,/*"春",0*/
0xFB,0xFF,0xBB,0xFF,0xBB,0xFF,0xBB,0xFF,0xA0,0xFF,0xBB,0xFF,0x3B,0x00,0xBB,0xFF,0xBB,0xFF,0xBB,0xF7,0xA0,0xEF,0xBB,0xF7,0x3B,0xF8,0xFB,0xFF,0xFB,0xFF,0xFF,0xFF,/*"节",1*/
0xFF,0xFE,0x1F,0xFF,0xFF,0xFF,0x00,0x00,0xEF,0xFF,0xDF,0x7E,0xF7,0xBE,0xF7,0xCE,0xF7,0xF2,0x00,0xFC,0xF7,0xF2,0xF7,0xCE,0x07,0xBE,0xFF,0x7E,0xFF,0x7E,0xFF,0xFF,/*"快",2*/
0xFF,0xFF,0xFF,0xDF,0x1F,0xEF,0x63,0xF7,0x7B,0xF9,0x7B,0xBF,0x7B,0x7F,0x0B,0x80,0x7D,0xFF,0x7D,0xFF,0x7C,0xFD,0x7D,0xFB,0x7F,0xF7,0x7F,0xCF,0xFF,0xFF,0xFF,0xFF,/*"乐",3*/
};
/*****n(us)延时子程序*****/
void DelayUs(uint N)
{
uint x ;
for(x=0;x<=N;x++);
}
/*****主函数*****/
void main(void)
{
uint i=0,j=0 ;
led1=0 ;
//主程序中只检测按键
while(1)
{
if(KEY==0)
{
j++;
if(j>740)
{
j=0 ;
}
for(i=j;i<30+j;i++)
{
P0=love[i*2];
P2=love[i*2+1];
DelayUs(60);
P0=0XFF;
P2=0XFF;
}
}
}
}
/*****END*****/
|