文件名称:s90控制舵机为什么不转
文件大小:3KB
文件格式:C
更新时间:2022-12-22 11:08:15
saS
#include "reg52.h"
typedef unsigned int u16;
typedef unsigned char u8;
sbit ControlPort=P3^5;
#define led P2
u8 ServePwmValue=1500;//?????????1500??
//?????????
void Timer0_Int0()
{
TMOD=0x01; //???????1???????/??????T0
TH0=0;
TL0=0;
TF0=0;
ET0=1; //?????ж?
}
//pwm s?????ж?
void TimerValue(u16 pwm)
{
u16 Value;
TR0=0;
Value=pwm;
TL0=Value; //??16λ????????8λ???????16λ???8λ???8λ
TH0=Value>>8;
TR0=1;
}
//???????
void DelayMs(u16 ms)
{
u16 i,j;
for(i=0;i<85;i++) //89???????85,12??е??????800
for(j=0;j