Arduino nano project with servo motor | How does work servo motor.
Arduino nano project with servo motor
Hello guys, Welcome back to my blog. We have already described 10 posts on this Arduino. These posts are created to be very easy to learn. Today we are going to talk about the servo motor that many people like to learn.OK, let’s go to today’s post.
What is the servo motor?
A servo motor usually includes a simple DC motor but it has a gear wheel system. Also, the servo motor includes a sensor system for measuring gear wheel rotation. So we can rotate it to the desired digress. Usually, the servo motor can rotate 0 to 180 degrees. You can also buy 360-degree servo motors in the market if you want. These servo motors are mainly used to make robotic arms. We can buy servo motors of different sizes in the market. It depends on the project we are doing. These servo motors can be rotated by the PWM signal on the Arduino board. You can use PWM pins on the Arduino board for that. The servo motor consists of three wires. The wire colors are orange, red, and brown. The red and brown wires are used to power the servo motor. The orange wire is used to rotate the servo motor to the required number of degrees. We can use a PWM signal for this purpose. These points are common to all servo motors.
Okay, let’s do a simple project using a servo motor. We use a very cheap servo motor for this project. The required components and how to do it step by step are as follows.
Let us learn something new from this code. It’s about libraries.
What is the Arduino library file?
A library is a file containing code issued by a company to make it easier for us to work with a device. The servo motor library file is included in the Arduino IDE. Include it as follows.
Create an object using any name you like.
Servo sritutech;
This code informs us about the PWM pin we are using.
void setup() {
sritutech.attach(3);
}
This code will be inserted into the Arduino board in the number of degrees required for the servo motor to rotate.
void loop() {
sritutech.write(0);
delay(400);
sritutech.write(180);
delay(400);
}
Step 4
Select board and port.
Step 5
Upload this code and enjoy it.
OK, let’s do this project using the Arduino Nano board. Follow the steps below.
Understand the code below and upload it to your Arduino board. Please comment on your questions below. We will meet in the next post. Have a good day. Bye-bye.
#include <Servo.h>
Servo sritutech;
void setup() {
sritutech.attach(9);//set arduino PWM pin D9
}
void loop() {
for (int a = 0 ; a <= 180 ; a++) {
sritutech.write(a);
delay(10);
}
for (int k = 179; k > 0 ; k--) {
sritutech.write(k);
delay(10);
}
}
Hello, welcome back. In this tutorial, we will learn how to make a line follower robot using Arduino. Also, this project mainly uses the 4-way line tracking sensor module. In…
Hello, welcome back. In this tutorial, we will learn how to make a Fire alarm security system using the Nodemcu and Blynk app. This project is mainly based on IoT…
Hello, welcome back. In this tutorial, we will learn what is the CJMCU 101 analog light sensor and how it works with an Arduino. Also, a light value detection project…
Hello, welcome back. In this tutorial, we will learn how to control a servo motor using a potentiometer and a Joystick module. We have presented in several previous articles how…
How to make a 4-way line tracking sensor module robot using Arduino Hello guys, welcome back. In this tutorial, we will learn how to make a 4-way line…
Hello, welcome back. In this tutorial, we will learn what is the mini PIR motion sensor and how to use it with Arduino. This sensor is also known as HC-SR…