標(biāo)題: 各位大神看看這個(gè)控制舵機(jī)程序,不能實(shí)現(xiàn)來回轉(zhuǎn)動(dòng) [打印本頁]

作者: 不如不見GYD    時(shí)間: 2017-6-29 21:18
標(biāo)題: 各位大神看看這個(gè)控制舵機(jī)程序,不能實(shí)現(xiàn)來回轉(zhuǎn)動(dòng)

#include "reg52.h"
unsigned char count;      
sbit pwm =P3^0 ;         
unsigned char jd;         
void delay(unsigned char i)
{
  unsigned char j,k;
  for(j=i;j>0;j--)
    for(k=125;k>0;k--);
}
void Time0_Init()         
{
TMOD = 0x01;            
IE   = 0x82;
TH0  = 0xfe;
TL0  = 0x33;     
    TR0=1;                 
}
void Time0_Int() interrupt 1
{
TH0  = 0xfe;            
TL0  = 0x33;
    if(count<jd)              
      pwm=1;                  
    else
      pwm=0;                  
    count=(count+1);         
    count=count%40;     
}


void main()
{
jd=1;
count=0;
Time0_Init();              
while(1)
{
        for(jd=1;jd<6;jd++)
        count=0;
        for(jd=5;jd>0;jd--)
        count=0;
}


}



作者: 殘缺的記憶    時(shí)間: 2017-6-29 23:17
轉(zhuǎn)太快了,給for里面把延時(shí)加上
作者: HC6800-ES-V2.0    時(shí)間: 2017-6-30 12:42
你的舵機(jī)是什么型號(hào)啊?
我這個(gè)程序,是控制SG90舵機(jī)的,你看看。

1.jpg (24.88 KB, 下載次數(shù): 95)

1.jpg

舵機(jī)的使用工程.rar

32.13 KB, 下載次數(shù): 29






歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1