材料:
1.無刷馬達一顆(網路購買)
2.simonk 30A 無刷電變
3.arduino NANO 一片
4.電源供應器一台


接線注意事項:

控制程式碼:
***********************************
#include <Servo.h>
Servo myservo; // create servo object to control a servo
void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
Serial.begin(9600);
myservo. writeMicroseconds (1000);
}
void loop() {
if(Serial.available()!=0){
char a = Serial.read();
if(a == 'A'){
myservo. writeMicroseconds (1500);
delay(20);
}
else if(a == 'B'){
myservo. writeMicroseconds (2100);
delay(20);
}
else if(a == 'S'){
myservo. writeMicroseconds (1000);
delay(20);
}
}
****************************************
重點:
1.不能直接以伺服馬達的控制給他角度
2.要透過給他PWM(myservo. writeMicroseconds (數值);)才比較好控制
3.調變器有它的可控制範圍,使用前記得看說明書
成果影片
沒有留言:
發佈留言