Sweep Servo Motor With Arduino Nano


32,945

22

13

Introduction: Sweep Servo Motor With Arduino Nano

Curious by nature. Like to know how things works & love to learn about them. Especially electrica...

Hello friends.

In this instructable, i have shown how to sweep a servo motor with Arduino Nano.

Generally servo motor is used where is low speed but with a high torque is needed. this work can be done by a geared motor too.

But servo motors are different from geared motors, servo motors can read it position & can rotate to given degrees.

Tools we will need.

  • Arduino Nano
  • A servo motor.

First of all attach servo motor to Nano like in the image above.

  • The yellow wire is signal wire which will be attached to Nano's digital pin 9.
  • The red wire is positive wire which will be attached to 5V.
  • The black wire is negative wire & it will be connected to GND.

all the hardware work is done, now move to software part.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Uploading Code

Attach the USB cable to Nano And PC.

Open the Arduino IDE software.

Go to File > Examples > Servo > Sweep.

Upload it to Nano.

When uploading is done.

The servo motor will follow commands given by Nano.

  • It will rotate to 0 degree at first.
  • Then one by one degree it will rotate to 180.
  • When it will reach to 180 degree.
  • It will do same process reversely & process goes on until you remove the power or upload the new sketch.

If you have any question or suggestion, you can write me in the comment section below. ^_^

Be the First to Share

    Recommendations

    • Trash to Treasure Contest

      Trash to Treasure Contest
    • Raspberry Pi Contest 2020

      Raspberry Pi Contest 2020
    • Wearables Contest

      Wearables Contest

    13 Discussions

    0
    guds777
    guds777

    7 months ago

    Arduino noob here. How do you control the nano to make the servo move. You got to use a pot or buttons physically connected to the nano to operate the servo.?

    0
    Bubbzo
    Bubbzo

    Reply 8 weeks ago

    This tutorial from Arduino has details on using a button to activate an LED. Just swap the LED code with the servo code and you should be good to go. https://www.arduino.cc/en/tutorial/switch

    0
    MohamedS58
    MohamedS58

    1 year ago on Step 1

    how can i control this servo motor by switch step by step forwade and backward

    0
    Bubbzo
    Bubbzo

    Reply 8 weeks ago

    There are tutorials on how to control Arduino with a switch. If you would like a reference on how to do that, try this tutorial out and experiment with adding it to this servo project. https://www.arduino.cc/en/tutorial/switch

    0
    keeran.parthipan
    keeran.parthipan

    6 months ago on Step 1

    If the code isn't uploading to the Arduino, perhaps you haven't installed 'Servo.h' .

    1. Download the library. I used GitHub. https://github.com/arduino-libraries/Servo
    (click on 'Clone or download', then 'Download ZIP')
    2. In Arduino IDE, go to Sketch -> Include Library -> Add .ZIP Library... and select the servo file from your downloads.

    Hopefully the code will work after this.

    0
    klotzmando
    klotzmando

    8 months ago

    It would save a lot of time if you had inserted the code instead of using a "screenshot". That way users could copy and paste the code to start testing quickly.
    Also, it should be suggested that if the nano does not upload it could be that the wrong processor was chosen. There are two entries for Atmega328p, one has the added text "(Old Bootloader)". In my case I have to use the old bootloader variant.

    1
    mp3lllm
    mp3lllm

    1 year ago

    Hey,

    How can i add a Pir and battry 9V?

    0
    KunalS54
    KunalS54

    1 year ago on Step 1

    why in my case the code is not uploading in Arduino nano??

    0
    manasm21
    manasm21

    2 years ago

    The computer is not detecting Nano. What to do?

    0
    aetoscy
    aetoscy

    3 years ago

    I want to use it to release a parachute in a bottle rocket project. How can I a countdown timer? Lets say 6 seconds after the battery connection to the arduino? Is there any ready timer for arduino?

    0
    TobiasF16
    TobiasF16

    Reply 3 years ago

    Hey, I dont know, if you need it any more... You can do a delay of the time you want to wait before the servo code. This should be work.

    Best wishes

    Tobi

    0
    DRAGUA1979
    DRAGUA1979

    4 years ago

    I thought it was yellow.

    0
    Gautam1807
    Gautam1807

    Reply 4 years ago

    thanks buddy, just realize after your comment.