Skip to main content

Testing servo motor with arduino

 Testing servo motor with arduino 

Components Needed:

  1. Arduino board (e.g., Arduino Uno)

  2. Servo motor

  3. Jumper wires

Steps for Connection:

  1. Servo Motor Pins:

    • Ground (GND): Usually the brown or black wire of the servo motor.

    • Power (VCC): Usually the red wire of the servo motor.

    • Control Signal (PWM): Usually the yellow, orange, or white wire of the servo motor.

  2. Connecting to Arduino:

    • Ground (GND): Connect the ground wire of the servo motor to one of the GND pins on the Arduino.

    • Power (VCC): Connect the power wire of the servo motor to the 5V pin on the Arduino.

    • Control Signal (PWM): Connect the control signal wire of the servo motor to digital pin 9 on the Arduino, as specified in the code by myservo.attach(9);

Connection


Arduino 

Servo motor 

VCC/ 5V

Red wire 

GND

Black Wire 

Yellow wire


Explanation:

  • Ground (GND): This connection ensures that the servo motor and the Arduino share a common ground, which is necessary for proper operation.

  • Power (VCC): The servo motor needs a power supply to operate. The 5V pin on the Arduino provides a suitable voltage for most standard hobby servo motors.

  • Control Signal (PWM): The control signal wire is connected to digital pin 9 on the Arduino. This pin will send PWM (Pulse Width Modulation) signals to the servo motor to control its position. The myservo.attach(9); function in the code specifies that pin 9 is used for this purpose.

This setup allows the Arduino to control the position of the servo motor by sending PWM signals through pin 9, as demonstrated in the loop() function of the provided code.


Circuit Diagram 


Arduino Code 


#include <Servo.h>  // Include the Servo library which allows us to control servo motors

Servo myservo;  // Create a Servo object named myservo to control a servo motor

void setup() {

  myservo.attach(9); // Attach the servo motor to pin 9 of the Arduino

}

void loop() {

  myservo.write(0);  // Set the servo position to 0 degrees

  delay(1000);       // Wait for 1000 milliseconds (1 second)

  

  myservo.write(90); // Set the servo position to 90 degrees

  delay(1000);       // Wait for 1000 milliseconds (1 second)

}




Comments

Popular posts from this blog

IOT based Weather monitoring system

  IOT based Weather monitoring system  Introduction In today's world, the importance of accurate and real-time weather monitoring cannot be overstated. Weather conditions significantly impact various aspects of life, from agriculture and transportation to disaster management and daily activities. With the advancement of technology, it is now possible to develop sophisticated yet affordable weather monitoring systems that can provide real-time data and alerts. One such innovative approach involves using the NodeMCU microcontroller and the DHT11 sensor. This project aims to design and implement a weather monitoring system that leverages these technologies to measure and report environmental parameters such as temperature and humidity. Objectives The primary objectives of this project are as follows: Design and Implementation: To design and implement a reliable weather monitoring system using the NodeMCU microcontroller and the DHT11 sensor. Real-time Data Acquisition: To acquire...

2017//2(b)//Engineering Eco//KU

A loan of $10,000 is to be repaid over a period of eight years. During the first four years, exactly half of the loan principal is to be repaid (along with accumulated compound interest) by a uniform series of payments of A1 dollar per year. The other half of the loan principal is to be repaid over four years, with accumulated interest, by a uniform series of payments of A2 dollar per year, If i=9% per year, what are A1 and A2?

2017//2(c)//Engineering Eco//KU

An apartment complex wishes to establish a fund at the end of 2004 that, by the end of the year 2021, will grow to an amount large enough to place new roofs on its 39 apartment units. Each new roof is estimated to cost $2,500 in 2019, at which time 13 apartments will be reroofed. In 2020, another 13 apartments will be reroofed, but the unit cost will be $2,625. The last 13 apartment will be reroofed in 2021 at a unit cost of $2,750. The annual effective interest rate that can be earned on this fund is 4%. How much money each year must be put aside (saved), starting at the end of 2005, to pay for all 39 new roofs? State any assumptions you make.