|
剛剛寫了MG995舵機(jī)的源碼,但是供電之后,只是感覺想要扭動它,比不通電時費(fèi)的力大了,但舵機(jī)還是不轉(zhuǎn)動,下面是源碼,大神們能不能說下是軟件的問題還是電壓的問題?
#include<reg52.h>
sbit pwm=P3^0;
unsigned char jb;
unsigned char count;
void time0_init()
{
TMOD=0x01;
IE=0x82;
TH0=0xfe;
TL0=0x33;
TR0=1;
}
void time0 interrupt 1
{
TH0=0xfe;
TL0=0x33;
if(count<jb)
{
pwm=1;
count=(count+1);
count=count%40;
}
else
{
pwm=0;
count++;
count=count%40;
}
}
void main()
{
pwm=0;
time0_init();
count=0;
jb=2;
while(1);
} |
|