arduino Mini 的學習之路..( Part -3 )



課目: 伺服馬達的控制  ( PWM )

Hitec HSR-8498HB 伺服馬達 ( 腳位接線圖 )

我這個實驗使用的是 Hitec HSR-8498HB 伺服馬達.
目前使用驅動模式選擇第一種已經成功.
這個馬達總共有3種模式,
1. Standard Pulse Mode (Pulse width 550 to 2450 Microseconds)
角度計算式 Servo Angle (degrees) = (Pulse Width (•S) – 1500) / 10

2. Extended Pulse Mode. (Pulse width 50 to 200 Microseconds) (未完成)

3. Serial Mode. (Pulse width 416 Microseconds) (未完成)

馬達的說明文件連結:
http://robosavvy.com/Builders/i-Bot/HSR8498HB%20Servo.pdf


^^ 上面影片的程式範例:

#include <Servo.h>

Servo myservo; // create servo object to control a servo

void setup()
{
Serial.begin( 19200 );
myservo.attach(9); //連接 Servo 信號到 Digital Pin 9
}

int angleVal=550;

void loop()
{
myservo.writeMicroseconds( angleVal ); //Pulse width 550 to 2450 Microseconds = Standard Pulse Mode

if ( angleVal + 100 <= 2450 )
{
angleVal += 100;
delay ( 1000 );
}
else angleVal = 550;

delay ( 300 );

int readdata=0;

readdata = myservo.read ();

Serial.println ( readdata );

}

沒有留言:

張貼留言