|
3#
樓主 |
發表於 2010-5-21 09:19:06
|
只看該作者
我這樣寫,好像還是不行~~~~
roboio_SetRBVer(RB_100);
rcservo_SetServo(0, RCSERVO_SERVO_DEFAULT_NOFB);
//初始化:把Channel 0和1切換成PWM輸出,其他channel為GPIO
if(rcservo_Initialize(RCSERVO_USECHANNEL0) == false)
{
//初始化失敗則印出錯誤訊息
printf("%s",roboio_GetErrMsg());
rcservo_Close();
return -1;
}
//進入PWM Mode
rcservo_EnterPWMMode();
while(true)
{
rcservo_SendPWMPulses(0, 20000L, 800L,100L);
rcservo_Outp(2,1);
printf("playing PWM_duty_left .\n");
while (!rcservo_IsPWMCompleted(0));
printf("finishing PWM_duty_left .\n");
Sleep(1000);
rcservo_SendPWMPulses(0, 20000L, 1500L,100L);
rcservo_Outp(2,0);
printf("playing PWM_duty_middle .\n");
while (!rcservo_IsPWMCompleted(0));
printf("finishing PWM_duty_middle .\n");
Sleep(1000);
rcservo_SendPWMPulses(0, 20000L, 2200L,100L);
rcservo_Outp(2,1);
printf("playing PWM_duty_right .\n");
while (!rcservo_IsPWMCompleted(0));
printf("finishing PWM_duty_right .\n");
Sleep(1000);
}
//結束程式
rcservo_Close();
return 0; |
|