17, Feb, 2019

Sample code to Connect SERVO motor with ARDUINO

Home Forums Arduino Discussions Sample code to Connect SERVO motor with ARDUINO

This topic contains 0 replies, has 1 voice, and was last updated by  kevin 1 week, 1 day ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #1038

    kevin
    Participant

    // Include the Servo library
    #include <Servo.h>
    // Declare the Servo pin
    int servoPin = 3;
    // Create a servo object
    Servo Servo1;
    void setup()
    {
    // We need to attach the servo to the used pin number
    Servo1.attach(servoPin);
    }

    void loop()
    {
    /* // Make servo go to 0 degrees
    Servo1.write(0);
    delay(1000);
    // Make servo go to 90 degrees
    Servo1.write(90);
    delay(1000); */
    // Make servo go to 180 degrees
    Servo1.write(180);
    delay(1000);
    Servo1.write(0);
    delay(1000);
    }

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.