Aprender a controlar un servomotor con Arduino // Learn to control a servomotor with Arduino

¡Hola compañeros de Hive!
Hoy les traigo un tutorial para que aprendan cómo programar el movimiento de un servomotor controlado por un potenciómetro utilizando una placa Arduino Uno. Este es un trabajo practico que a mis alumnos les encanta hacer , es bastante didáctico y divertido.

Circuito eléctrico:

serv.png
servo.png

¿Qué necesitamos?

Arduino Uno: Nuestra placa de microcontrolador favorita.

ardddd.jpg

Servomotor: Un motor que puede girar a posiciones específicas.

ssssssssssssssssssssss.png

Potenciómetro: Una resistencia variable en mi circuito use de 5k , tambien podria ser de 10k.

potenciometro.png

Cables de conexión: Para conectar todo.

cables.jpg

Fuente de alimentación: Generalmente la del propio Arduino sirve(Aunque si exigimos que el servomotor haga mucha fuerza , vamos a necesitar una fuente externa SI o SI)

fuente de tension.jpg

Video de como funciona el programa de mis alumnos:

Programación:

#include <Servo.h>
Servo servito;
int angulo;
int lectura;
void setup() {
servito.attach(9);
}
void loop() {
lectura=analogRead(A0);
angulo=map(lectura,0,1023,0,179);
servito.write(angulo);
delay(20);
}

Espero que puedan disfrutar experimentando con este proyecto. Las conexiones y la programación son bastante simples, así que estoy seguro de que lo lograrán sin problemas. Si tienen alguna pregunta o necesitan ayuda, no duden en dejarla en los comentarios.
Un abrazo compañeros!


Hello fellow Hive!
Today I bring you a tutorial so you can learn how to program the movement of a servomotor controlled by a potentiometer using an Arduino Uno board. This is a practical job that my students love to do, it is quite educational and fun.

Electrical circuit:

serv.png
servo.png

What do we need?

Arduino Uno: Our favorite microcontroller board.

ardddd.jpg

Servomotor: A motor that can rotate to specific positions.

ssssssssssssssssssssss.png

Potentiometer: A variable resistor in my example I used a 10k linear pot

potenciometro.png

Connection cables: To connect everything.

cables.jpg

Power supply: Generally the Arduino itself works (Although if we require the servomotor to exert a lot of force, we will need an external source YES or YES)

fuente de tension.jpg

Video of how my students' program works:

Programming:

#include <Servo.h>
Servo servito;
int angulo;
int lectura;
void setup() {
servito.attach(9);
}
void loop() {
lectura=analogRead(A0);
angulo=map(lectura,0,1023,0,179);
servito.write(angulo);
delay(20);
}

I hope you can enjoy experimenting with this project. The connections and programming are pretty simple, so I'm sure you'll get it done without a problem. If you have any questions or need help, don't hesitate to leave them in the comments.
A hug colleagues!

Sort:  

Congratulations @tecnotronics! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)

You published more than 20 posts.
Your next target is to reach 30 posts.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP