資源簡介
利用meg16輸出多路pwm,可用來控制多個舵機,在做舞蹈機器人的時候很有幫助
代碼片段和文件信息
/*角度值:15度500us(10)——215度2500us(50)
?端口A0——A5???B0——B5????C0——C5???*/
#include
#include
#define?uint?unsigned?int
#define?uchar?unsigned?char?
#define?dt?70
#define?sp?18
#pragma?interrupt_handler??timer0:10
#pragma?interrupt_handler?timer1:9
uint?base0=0base1=0;
uchar?ik;
uint?j=0;
uchar??s[18]={1415142171313135141251468171214};
uchar??std[18]={146142141313135512514610171212};
void?delay(uint?s)????//n秒延時
{
????????uint?ij;
for(i=0;i ???{
???for(j=0;j<1141;j++);
???????}
}
void??chushi()??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
{
?uchar?i;
?for(i=0;i<18;i++)
????s[i]=std[i];
}
void?delay_ms(int?msec)//ms延遲函數
{
int?count;???????????????????
TCCR2?|=?(1< for?(count?=?0;?count? {
TCNT2?=?0x00;
while(TCNT2?250);
}
}
/**************
- 上一篇:SSH框架圖解.xmind
- 下一篇:qt觸摸屏
評論
共有 條評論