用51控制16路舵机控制板
动作很多吗?用中断不够吧?
实在不行你就试试定时吧。
用中断啊。在中断里面用一个flag。当flag==1;时。就执行舵机运动的程序啊!
十几个动作 用上位机程序可以控制,但是c不会写。
试试看吧 求教
发一个51单片机舵机控制代码给你瞧瞧
void main()
{
Timer0Init();
angle_count=7;
Delayms(500);//先回原位
while(1)
{
for(angle_count=7;angle_count<23;angle_count++)
Delayms(30);
for(angle_count=23;angle_count>7;angle_count--)
Delayms(30);
}
}
/*******************************************************************************
* 函 数 名 :Timer0Int
* 函数功能 :定时器0中断函数 , 每隔TIME_US ms进入
* 输 入 :无
* 输 出 :无
*******************************************************************************/
void Timer0Int() interrupt 1
{
TH0=(65536-(FOSC/12*TIME_US)/1000000)/256;
TL0=(65536-(FOSC/12*TIME_US)/1000000)%256;
count++;
if(count > 200)
count=0;
if(count<angle_count)
contrl_out=1;
else
contrl_out=0;
}
