SG90 Servos 9g 모터 구입하기>>

회로결선:

  • 오렌지색: 데이터(제어) 단자
  • 빨간색: (+) 전원 단자
  • 밤색: (-) 접지 단자

Specifications:

Weight: 9g
Dimension: 23×12.2x29mm
Stall torque: 1.8kg/cm(4.8v)
Gear: Nylon gear set
Operating speed: 0.1sec/60degree(4.8v)
Operating voltage: 4.8v
Temperature range: 0c_ 55c
Dead band width: 1us
Power Supply: Through External Adapter
servo wire length: 25 cm
Servo Plug: JR (Fits JR and so on)

ESP8266 ESP-12E 모듈을 위한 Arduino Code

회로결선:
– 오렌지색: 데이터(제어) 단자: ESP-12E GPIO 5
– 빨간색: (+) 전원 단자 : ESP-12E VCC
– 밤색: (-) 접지 단자: ESP-12E GND

Servo 라이브러리 설치:
Arduino IDE 메뉴> Sketch > Include Library> Manage Libraries …
에서 Servo 로 검색하여 설치합니다.

SG90-Servo.ino

/**The MIT License (MIT)

Copyright (c) 2016 by Seokjin Seo

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

See more at http://usemodj.com
*/

#include <Servo.h>

// setup servo
#define SERVORIGHT   50
#define SERVOCENTRE 100
#define SERVOLEFT   150
#define SERVOPIN     5      // GPIO 5

Servo servo;

void setup() {
    Serial.begin(115200);
    Serial.println(" SG90 Servo");
    // set the servo data pin
    servo.attach(SERVOPIN);

}

void loop() {
    servo.write(SERVOLEFT);
    delay(300);

    servo.write(SERVORIGHT);
    delay(600);

    servo.write(SERVOCENTRE);
    delay(300);

    delay(2000); // 2 sec
}

Leave a Reply