티스토리 뷰

참조: https://www.eleparts.co.kr/EPX3D44D

  http://kocoafab.cc/tutorial/view/354

       서보모터 제어: http://kocoafab.cc/tutorial/view/446






제품 규격

 3극 페라이트 

 나일론 기어

 탑 볼 베어링

 동작 전압: 4.8V~6.0V

 동작 속도: 0.12sec/60 degree

 출력 토크: 1.6kg/cm 4.8V

 크기: 21.5 x 11.8 x 22.7mm

 무게: 9g



케이블 핀 맵

GND 라인

 검은색 또는 갈색

 VCC 라인

 빨간색 

 신호라인

 흰색 또는 주황색 



브레드보드 레이아웃(아두이노 우노)




아두이노 샘플 소스

// Servo Sg-90 test by Servo library


#include <Servo.h> 


#define LED_STATUS                13

#define SERVO_PIN                 6


#define MY_MIN_PULSE_WIDTH       590     // the shortest pulse sent to a servo

#define MY_MAX_PULSE_WIDTH      2560     // the longest pulse sent to a servo


#define LEFT_DIRECTION 30

#define STRAIGHT_DIRECTION 105

#define RIGHT_DIRECTION 180


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


int current_angle = 0;          // servo current angle

int current_microsecond = 0;    // servo current pulse width

 

void setup() 

  pinMode(LED_STATUS, OUTPUT);

  

  Serial.begin(9600);

  Serial.println("Servo Ready");

  

  myservo.attach(SERVO_PIN, MY_MIN_PULSE_WIDTH, MY_MAX_PULSE_WIDTH);  // attaches the servo to the servo object

 

void loop() 

  int index1 = 0;

  int index2 = 0;

  int test1 = 0;


  digitalWrite(LED_STATUS, HIGH);

/*

  for(index1 = 0; index1 < 91; index1+=1)        // start and end - angle

  //for(index1 = 590; index1 < 2450; index1+=20)  // start - microseconds

  //for(index1 = 2300; index1 < 2560; index1+=2)  // end - microseconds

  {

    for(index2 = 0; index2 < 2; index2++)

    {

      myservo.write(index1);               // sets the servo position according to the scaled value

      //myservo.writeMicroseconds(index1); // Write pulse width in microseconds

      delay(15);                           // waits for the servo to get there

    }

    

    current_angle = 0;

    //current_microsecond = 0;

    

    current_angle = myservo.read();                        // returns current pulse width as an angle between 0 and 180 degrees

    //current_microsecond = myservo.readMicroseconds();            // returns current pulse width in microseconds for this servo (was read_us() in first release)


    Serial.print("write: ");

    Serial.print(index1);

    Serial.print(", read: ");

    Serial.print(current_angle);

    //Serial.print(current_microsecond);

    Serial.println(" degree");

    //Serial.println(" micro second");

  }

 */

  

  myservo.write(LEFT_DIRECTION);

  delay(2000);

  myservo.write(STRAIGHT_DIRECTION);

  delay(2000);

  myservo.write(RIGHT_DIRECTION);

  delay(2000);


  digitalWrite(LED_STATUS,LOW);

  

  delay(500);                           // waits for the servo to get there

  


사용예정 핀(Arduino Nano 3.0)

- SERVO_PIN 6

- GND

- VCC














댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함