1. Do not share user accounts! Any account that is shared by another person will be blocked and closed. This means: we will close not only the account that is shared, but also the main account of the user who uses another person's account. We have the ability to detect account sharing, so please do not try to cheat the system. This action will take place on 04/18/2023. Read all forum rules.
    Dismiss Notice
  2. For downloading SimTools plugins you need a Download Package. Get it with virtual coins that you receive for forum activity or Buy Download Package - We have a zero Spam tolerance so read our forum rules first.

    Buy Now a Download Plan!
  3. Do not try to cheat our system and do not post an unnecessary amount of useless posts only to earn credits here. We have a zero spam tolerance policy and this will cause a ban of your user account. Otherwise we wish you a pleasant stay here! Read the forum rules
  4. We have a few rules which you need to read and accept before posting anything here! Following these rules will keep the forum clean and your stay pleasant. Do not follow these rules can lead to permanent exclusion from this website: Read the forum rules.
    Are you a company? Read our company rules

Tutorial Written outline for Tutorial #7: Servo motor.

Discussion in 'New users start here - FAQ' started by Pat Regan, Dec 19, 2022.

  1. Pat Regan

    Pat Regan DIY Fokker D7F Flight Simulator Gold Contributor

    Joined:
    Mar 12, 2021
    Messages:
    18
    Balance:
    195Coins
    Ratings:
    +1 / 0 / -0
    My Motion Simulator:
    SCN5, Motion platform, 4DOF
    If this is in the wrong place to post this, we can move it.

    Bryan Vines is well known to post video tutorials about working with the Elegoo Arduino starter kit; which I just received.

    As a beginner, I find it helps to watch the video and then make a written outline I can work from when setting up the hardware and writing the code.

    Today I'm learning how to get the Arduino to control a 12-volt tarp motor. Closest tutorial I could find was #7 where Bryan shows how to operate the little servo motor that comes with the starter kit. (If it starts in the middle, my mistake; slide back to the beginning.)



    And below is my working outline of Bryan's video #7: step by step; lines of code, et al. I appreciate the help I'm receiving here and hope this helps someone who's just getting started.

    I've tried to edit it correctly but if you see any typos or errors, shout out and I'll fix it.

    VBR,

    Pat


    ARDUINO CONTROLLING SERVO MOTOR


    GENERAL INFO:

    We’ll be using code and a code library to control a servo motor: which is an electric motor with gears turning an output shaft, a control board, and a variable resistor.

    A variable resistor is like an “electronic volume knob”; as the servo moves through range of motion, it “turns” that volume knob.

    Control board in servo monitors resistance to determine how far output shaft has turned; will stop rotation at the point the control board has been told to go to.

    The servo plug has three wires: Power, Ground, and Signal.

    How does it control via only one wire? Pulse Width Modulation (PWM) tells controller where to go through single Signal wire. Length of pulse determines output shaft positioning: long pulse to maximum servo position; short pulse to minimum servo position

    COMPONENTS:

    1 UNO; 3 connecting wires: black, red, and orange; 1 Servo and 1 control horn.

    ASSEMBLY:

    Black wire from Arduino ground socket to Brown wire of servo plug.

    Red wire from Arduino 5V Power socket to Red wire of servo plug.

    Orange wire from ~9 output socket of Arduino to Orange wire of servo plug. (~ indicates PWM is available at this socket.)

    CODE:

    We’ll use Code Library to provide detailed information on operating this servo; to find right one:

    Launch IDE and start a sketch if one didn’t get created for you.

    TOOLS MENU: Manage Library

    In Library Manager Window: type servo and press return. Servo sketch is now highlighted. Select it and go to sketch.

    Return down twice and mouse back up to start at top of Sketch. Added code is shown in bold black font below.

    #include <Servo.h> (note: no semicolon here!)

    Return down twice

    Servo myServo;

    Return down twice

    int servoDelay=1000; (1000 milisecond delay between signals)

    int servoMax=180; (maximum degrees of rotation is 180)

    int servoMin=0; (minimum degrees of rotation is 0)



    Mouse down below “void setup” put your setup code here to run once:


    myServo.attach(9); (identifies PWM connection..Setup is now complete.)



    Mouse down below “void loop” put your main code here to run repeatedly:


    myServo.write(servoMax);

    delay(servoDelay);


    Return down twice

    myServo.write(servoMin);

    delay(servoDelay); (code is now complete)



    TO SAVE SKETCH: Click FILE, SAVE, name it ServoSweep, and Save.


    Connect Uno to Computer via USB cable.


    Before uploading, make sure:

    click TOOLS, then BOARD; make sure Arduino Uno is selected.

    click TOOLS, then PORT; make sure port with Arduino Uno is selected.


    Click CHECKMARK to compile sketch; correct errors if necessary.


    Click ARROW to upload compiled sketch to Uno; servo should activate: rotating left & right with a one second delay.


    ADDITIONAL:


    You may now experiment with variable settings to change servo performance.


    Video describes how to enable Servo to serve as a countdown timer.


    Next, I must consider and study similarities & differences between connecting this servo and connecting a tarp motor. Working on it!


    Enjoy!
    Last edited: Dec 19, 2022
  2. amilivian

    amilivian New Member

    Joined:
    Mar 22, 2022
    Messages:
    17
    Occupation:
    INGENIERO EN TELECOMUNICACIONES
    Location:
    CATAMARCA ARGENTINA
    Balance:
    114Coins
    Ratings:
    +6 / 0 / -0
    My Motion Simulator:
    2DOF, 3DOF, Arduino
    What a good contribution it helped me to learn a little more about some variable configurations in the performance of a servo, thanks