• Home
  • my project
  • About
    • About me
    • @info
  • session/Assignments

    this week assignment is about output devices

    group assignment https://fabacademy.org/2023/labs/rwanda/Group_Assignment/output_devices.html
    for this assignment of output devices i have decided to use servo motors which are widely used in many
    applications such robotics, automation machines, industrial machines
    servor motor
    Servo motors are geared DC motors that have an integrated servomechanism with a feedback loop to allow precise positioning of the motor shaft.
    A high gear ratio allows a small servo to have an impressive torque rating. Most servos are limited in rotation to either 180 or 270 degrees, with 180-degree servo motors being more common.
    There are specially modified servo motors that can rotate beyond 360-degrees, but we won’t be working with those today.
    Servo motors come in a wide range of sizes and can be controlled either with an analog PWM signal or with a digital I/O signal.
    The inexpensive servos we use for hobbyist applications are usually analog servo motors, which are the types we will be using today.
    from LINK HERE there's more about servo motors

    here's pinouts of the servo motor where to connect for making connections to controller, refer from HERE

    so i connected the programmer and board i have made in recent week follow LINK HERE to see how i made them

    setting up wiring connections



    i opened arduino selected the right board and port

    when i compiled the codes i kept seeing this error so i tried to find solution on internet but i couldn't find any
    so i found that there's esp32 servo library
    https://github.com/madhephaestus/ESP32Servo
    which exactly worked

    so i downloaded it from given link above and it worked
    and installed as shown below click on sketch tab>>include library>> add .zip library and select the downloaded zip file

    then i added this following codes and i uploaded it as mentioned above
    
            
           #include 
           
           Servo myservo; 
           
           int pos = 0;    // variable to store the servo position
         
           #if defined(ARDUINO_ESP32S2_DEV)
           int servoPin = 17;
           #else
           int servoPin = 18;
           #endif
           
           void setup() {
             // Allow allocation of all timers
             ESP32PWM::allocateTimer(0);
             ESP32PWM::allocateTimer(1);
             ESP32PWM::allocateTimer(2);
             ESP32PWM::allocateTimer(3);
             myservo.setPeriodHertz(50);    // standard 50 hz servo
             myservo.attach(servoPin, 1000, 2000); // attaches the servo on pin 18 to the servo object
           }
           
           void loop() {
           
             for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
               // in steps of 1 degree
               myservo.write(pos);    // tell servo to go to position in variable 'pos'
               delay(15);             // waits 15ms for the servo to reach the position
             }
             for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
               myservo.write(pos);    // tell servo to go to position in variable 'pos'
               delay(15);             // waits 15ms for the servo to reach the position
             }
           }
           
    
          


@weekly session