{"id":1810,"date":"2025-06-18T10:31:05","date_gmt":"2025-06-18T10:31:05","guid":{"rendered":"https:\/\/learnbydoing.dev\/?p=1810"},"modified":"2026-01-10T22:45:01","modified_gmt":"2026-01-10T22:45:01","slug":"how-to-control-a-servo-motor-with-arduino-uno","status":"publish","type":"post","link":"https:\/\/learnbydoing.dev\/how-to-control-a-servo-motor-with-arduino-uno\/","title":{"rendered":"How to Control a Servo Motor with Arduino"},"content":{"rendered":"<div data-elementor-type=\"wp-post\" data-elementor-id=\"1810\" class=\"elementor elementor-1810\" data-elementor-post-type=\"post\">\n\t\t\t\t<div class=\"elementor-element elementor-element-e28ab35 e-flex e-con-boxed e-con e-parent\" data-id=\"e28ab35\" data-element_type=\"container\" data-e-type=\"container\" id=\"content\" data-settings=\"{&quot;background_background&quot;:&quot;classic&quot;}\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t<div class=\"elementor-element elementor-element-62ab6e3 e-con-full e-flex e-con e-child\" data-id=\"62ab6e3\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t<div class=\"elementor-element elementor-element-62ab203 elementor-align-center elementor-widget elementor-widget-post-info\" data-id=\"62ab203\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"post-info.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<ul class=\"elementor-inline-items elementor-icon-list-items elementor-post-info\">\n\t\t\t\t\t\t\t\t<li class=\"elementor-icon-list-item elementor-repeater-item-2c98363 elementor-inline-item\" itemprop=\"about\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"elementor-icon-list-text elementor-post-info__item elementor-post-info__item--type-terms\">\n\t\t\t\t\t\t\t\t\t\t<span class=\"elementor-post-info__terms-list\">\n\t\t\t\t<span class=\"elementor-post-info__terms-list-item\">Arduino<\/span>, <span class=\"elementor-post-info__terms-list-item\">Electronics<\/span>, <span class=\"elementor-post-info__terms-list-item\">Tutoriales<\/span>\t\t\t\t<\/span>\n\t\t\t\t\t<\/span>\n\t\t\t\t\t\t\t\t<\/li>\n\t\t\t\t<\/ul>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-0650e10 e-con-full e-flex e-con e-child\" data-id=\"0650e10\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t<div class=\"elementor-element elementor-element-ac19582 elementor-view-default elementor-widget elementor-widget-icon\" data-id=\"ac19582\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"icon.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-icon-wrapper\">\n\t\t\t<div class=\"elementor-icon\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"75\" height=\"75\" viewbox=\"0 0 75 75\" fill=\"none\"><path d=\"M74.9999 75H13.1889V73.0002H71.5859L0.460938 1.87521L1.87515 0.460999L73.0001 71.586V13.1889H74.9999V75Z\" fill=\"white\"><\/path><\/svg>\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-47aa245d e-flex e-con-boxed e-con e-parent\" data-id=\"47aa245d\" data-element_type=\"container\" data-e-type=\"container\" data-settings=\"{&quot;background_background&quot;:&quot;classic&quot;}\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-206a001 elementor-widget elementor-widget-image\" data-id=\"206a001\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img fetchpriority=\"high\" decoding=\"async\" width=\"1920\" height=\"1080\" src=\"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/06\/Servomotore-Animazione-_2_-1.webp\" class=\"attachment-full size-full wp-image-2084\" alt=\"\" srcset=\"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/06\/Servomotore-Animazione-_2_-1.webp 1920w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/06\/Servomotore-Animazione-_2_-1-300x169.webp 300w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/06\/Servomotore-Animazione-_2_-1-1024x576.webp 1024w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/06\/Servomotore-Animazione-_2_-1-768x432.webp 768w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/06\/Servomotore-Animazione-_2_-1-1536x864.webp 1536w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/06\/Servomotore-Animazione-_2_-1-18x10.webp 18w\" sizes=\"(max-width: 1920px) 100vw, 1920px\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-4bc31ca3 elementor-widget elementor-widget-text-editor\" data-id=\"4bc31ca3\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Servo motors are widely used in robotics, automation, and RC models because they can move to specific angles with precision. In this tutorial, you\u2019ll learn how to connect a servo motor to an Arduino Uno and control its position with simple code.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-324d52d elementor-widget elementor-widget-text-editor\" data-id=\"324d52d\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h3 data-start=\"1857\" data-end=\"1885\">\u00a0\ud83d\udcdd Required Components<\/h3><ul><li data-start=\"704\" data-end=\"724\"><p data-start=\"706\" data-end=\"724\">1\u00d7 Arduino Uno<br \/><br \/><\/p><\/li><li data-start=\"725\" data-end=\"766\"><p data-start=\"727\" data-end=\"766\">1\u00d7 Servo Motor (like SG90 or MG90S)<br \/><br \/><\/p><\/li><li data-start=\"767\" data-end=\"801\"><p data-start=\"769\" data-end=\"801\">3\u00d7 Male-to-male jumper wires<br \/><br \/><\/p><\/li><li data-start=\"802\" data-end=\"832\"><p data-start=\"804\" data-end=\"832\">1\u00d7 USB cable for Arduino<\/p><\/li><\/ul>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-12a4ca0 elementor-widget elementor-widget-text-editor\" data-id=\"12a4ca0\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h3 data-start=\"1857\" data-end=\"1885\">\u00a0\ud83d\udcd6 How a Servo Motor Works<\/h3><p data-start=\"188\" data-end=\"545\">A servo motor is a small device that can rotate to a specific position and hold it there. It\u2019s different from a regular DC motor, which spins continuously, because a servo moves to a precise angle based on the signal it receives. This makes it perfect for projects where you need accurate control, like moving the arm of a robot or steering a small vehicle.<\/p><p data-start=\"547\" data-end=\"1045\">The servo receives a control signal through a technique called PWM (Pulse Width Modulation). By changing the width of this signal, you tell the servo which angle to move to \u2014 typically between 0\u00b0 and 180\u00b0. Inside, the servo has a small motor and a control circuit that interprets the signal and adjusts the position accordingly. Thanks to Arduino\u2019s built-in Servo library, you don\u2019t have to manage these signals manually: you simply tell the servo the angle you want, and the library does the rest.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-e625dc8 elementor-widget elementor-widget-image\" data-id=\"e625dc8\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" width=\"1152\" height=\"648\" src=\"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/06\/Servomotore-Animazione.gif\" class=\"attachment-full size-full wp-image-2088\" alt=\"\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-fe69a81 elementor-widget elementor-widget-text-editor\" data-id=\"fe69a81\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h2 data-start=\"2039\" data-end=\"2065\">\ud83d\udcca Wiring Connections<\/h2><div class=\"_tableContainer_16hzy_1\"><table class=\"w-fit min-w-(--thread-content-width)\" data-start=\"1298\" data-end=\"1498\"><thead data-start=\"1298\" data-end=\"1337\"><tr data-start=\"1298\" data-end=\"1337\"><th data-start=\"1298\" data-end=\"1322\" data-col-size=\"sm\">Servo Wire<\/th><th data-start=\"1322\" data-end=\"1337\" data-col-size=\"sm\">Arduino Uno<\/th><\/tr><\/thead><tbody data-start=\"1377\" data-end=\"1498\"><tr data-start=\"1377\" data-end=\"1416\"><td data-start=\"1377\" data-end=\"1401\" data-col-size=\"sm\">Brown\/Black (GND)<\/td><td data-start=\"1401\" data-end=\"1416\" data-col-size=\"sm\">GND<\/td><\/tr><tr data-start=\"1417\" data-end=\"1456\"><td data-start=\"1417\" data-end=\"1441\" data-col-size=\"sm\">Red (+5V)<\/td><td data-start=\"1441\" data-end=\"1456\" data-col-size=\"sm\">5V<\/td><\/tr><tr data-start=\"1457\" data-end=\"1498\"><td data-start=\"1457\" data-end=\"1481\" data-col-size=\"sm\">Orange\/Yellow (Signal)<\/td><td data-start=\"1481\" data-end=\"1498\" data-col-size=\"sm\">Digital pin 9<\/td><\/tr><\/tbody><\/table><\/div>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-1bda844 elementor-widget elementor-widget-image\" data-id=\"1bda844\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" width=\"800\" height=\"450\" src=\"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/06\/Servomotore-Animazione-3-1024x576.png\" class=\"attachment-large size-large wp-image-2092\" alt=\"\" srcset=\"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/06\/Servomotore-Animazione-3-1024x576.png 1024w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/06\/Servomotore-Animazione-3-300x169.png 300w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/06\/Servomotore-Animazione-3-768x432.png 768w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/06\/Servomotore-Animazione-3-1536x864.png 1536w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/06\/Servomotore-Animazione-3-18x10.png 18w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/06\/Servomotore-Animazione-3.png 1920w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-e1ef5c9 elementor-widget elementor-widget-text-editor\" data-id=\"e1ef5c9\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h3 data-start=\"1857\" data-end=\"1885\">\ud83d\udce6 Complete Arduino Code<\/h3><p data-start=\"1922\" data-end=\"2017\">We\u2019ll use the built-in <strong data-start=\"1945\" data-end=\"1954\">Servo<\/strong> library in Arduino IDE to make it easier to control the motor.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-1ba2cef elementor-widget elementor-widget-code-highlight\" data-id=\"1ba2cef\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"prismjs-tomorrow copy-to-clipboard\">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-cpp line-numbers\">\n\t\t\t\t<code readonly=\"true\" class=\"language-cpp\">\n\t\t\t\t\t<xmp>#include <Servo.h>  \/\/ Include the Servo library\r\n\r\nServo ServoMotor;   \/\/ Create a Servo object\r\n\r\nvoid setup() {\r\n  ServoMotor.attach(9);  \/\/ Attach the servo to digital pin 9\r\n}\r\n\r\nvoid loop() {\r\n  ServoMotor.write(0);    \/\/ Move to 0 degrees\r\n  delay(1000);            \/\/ Wait 1 second\r\n\r\n  ServoMotor.write(90);   \/\/ Move to 90 degrees\r\n  delay(1000);            \/\/ Wait 1 second\r\n\r\n  ServoMotor.write(180);  \/\/ Move to 180 degrees\r\n  delay(1000);            \/\/ Wait 1 second\r\n}\r\n\r\n<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-7a888ec elementor-widget elementor-widget-text-editor\" data-id=\"7a888ec\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h3><b>\ud83d\udd0e\u00a0<\/b><b>Breaking down the Code<\/b><\/h3><p>Let\u2019s review the code section by section:<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-455a2f8 elementor-widget elementor-widget-text-editor\" data-id=\"455a2f8\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h5 data-start=\"1857\" data-end=\"1885\">Include the Servo library<\/h5><p>Adds the Servo library, providing functions to control servo motors.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-01f8801 elementor-widget elementor-widget-code-highlight\" data-id=\"01f8801\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"prismjs-tomorrow copy-to-clipboard\">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-cpp line-numbers\">\n\t\t\t\t<code readonly=\"true\" class=\"language-cpp\">\n\t\t\t\t\t<xmp>#include <Servo.h>\r\n\r\n<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-76c281e elementor-widget elementor-widget-text-editor\" data-id=\"76c281e\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h5 data-start=\"1857\" data-end=\"1885\">Create a Servo object<\/h5>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-f57c6ae elementor-widget elementor-widget-code-highlight\" data-id=\"f57c6ae\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"prismjs-tomorrow copy-to-clipboard\">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-cpp line-numbers\">\n\t\t\t\t<code readonly=\"true\" class=\"language-cpp\">\n\t\t\t\t\t<xmp>Servo ServoMotor;\r\n<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-b17443a elementor-widget elementor-widget-text-editor\" data-id=\"b17443a\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Creates a Servo object named <code data-start=\"2926\" data-end=\"2938\">ServoMotor<\/code> to control the motor.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-8141c6a elementor-widget elementor-widget-text-editor\" data-id=\"8141c6a\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h5 data-start=\"1857\" data-end=\"1885\">Setup Function<\/h5>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-6503883 elementor-widget elementor-widget-code-highlight\" data-id=\"6503883\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"prismjs-tomorrow copy-to-clipboard\">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-cpp line-numbers\">\n\t\t\t\t<code readonly=\"true\" class=\"language-cpp\">\n\t\t\t\t\t<xmp>void setup() {\r\n  ServoMotor.attach(9);\r\n}\r\n<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-2547d99 elementor-widget elementor-widget-text-editor\" data-id=\"2547d99\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Links the servo motor control wire to digital pin 9.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-bdbed67 elementor-widget elementor-widget-text-editor\" data-id=\"bdbed67\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h5 data-start=\"1857\" data-end=\"1885\">Main Loop<\/h5>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-d361b1c elementor-widget elementor-widget-code-highlight\" data-id=\"d361b1c\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"prismjs-tomorrow copy-to-clipboard\">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-cpp line-numbers\">\n\t\t\t\t<code readonly=\"true\" class=\"language-cpp\">\n\t\t\t\t\t<xmp>void loop() {\r\n  ServoMotor.write(0);\r\n  delay(1000);\r\n\r\n  ServoMotor.write(90);\r\n  delay(1000);\r\n\r\n  ServoMotor.write(180);\r\n  delay(1000);\r\n}\r\n<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-b51cf90 elementor-widget elementor-widget-text-editor\" data-id=\"b51cf90\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<ul><li data-start=\"3329\" data-end=\"3374\"><p data-start=\"3331\" data-end=\"3374\">Moves the servo to <strong data-start=\"3350\" data-end=\"3356\">0\u00b0<\/strong>, waits 1 second<br \/><br \/><\/p><\/li><li data-start=\"3375\" data-end=\"3411\"><p data-start=\"3377\" data-end=\"3411\">Moves to <strong data-start=\"3386\" data-end=\"3393\">90\u00b0<\/strong>, waits 1 second<br \/><br \/><\/p><\/li><li data-start=\"3412\" data-end=\"3449\"><p data-start=\"3414\" data-end=\"3449\">Moves to <strong data-start=\"3423\" data-end=\"3431\">180\u00b0<\/strong>, waits 1 second<br \/><br \/><\/p><\/li><li data-start=\"3450\" data-end=\"3469\"><p data-start=\"3452\" data-end=\"3469\">Repeats forever<br \/><br \/><\/p><\/li><\/ul>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-c92ae44 elementor-widget elementor-widget-text-editor\" data-id=\"c92ae44\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h3>\ud83d\ude80 Uploading the Code to Arduino<\/h3><ol data-start=\"3514\" data-end=\"3730\"><li data-start=\"3514\" data-end=\"3561\"><p data-start=\"3517\" data-end=\"3561\">Connect Arduino Uno to your computer via USB<br \/><br \/><\/p><\/li><li data-start=\"3562\" data-end=\"3585\"><p data-start=\"3565\" data-end=\"3585\">Open the Arduino IDE<br \/><br \/><\/p><\/li><li data-start=\"3586\" data-end=\"3612\"><p data-start=\"3589\" data-end=\"3612\">Copy and paste the code<br \/><br \/><\/p><\/li><li data-start=\"3613\" data-end=\"3654\"><p data-start=\"3616\" data-end=\"3654\">Select <strong data-start=\"3623\" data-end=\"3654\">Tools &gt; Board &gt; Arduino Uno<br \/><br \/><\/strong><\/p><\/li><li data-start=\"3655\" data-end=\"3685\"><p data-start=\"3658\" data-end=\"3685\">Select the correct <strong data-start=\"3677\" data-end=\"3685\">Port<br \/><br \/><\/strong><\/p><\/li><li data-start=\"3686\" data-end=\"3730\"><p data-start=\"3689\" data-end=\"3730\">Click <strong data-start=\"3695\" data-end=\"3705\">Upload<\/strong> (the right arrow button)<br \/><br \/><\/p><\/li><\/ol><p data-start=\"3732\" data-end=\"3790\">The servo motor should now move between 0\u00b0, 90\u00b0, and 180\u00b0.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>","protected":false},"excerpt":{"rendered":"<p>Servo motors are widely used in robotics, automation, and RC models because they can move to specific angles with precision. In this tutorial, you\u2019ll learn how to connect a servo motor to an Arduino Uno and control its position with simple code. \u00a0\ud83d\udcdd Required Components 1\u00d7 Arduino Uno 1\u00d7 Servo Motor (like SG90 or MG90S) [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":2084,"comment_status":"closed","ping_status":"open","sticky":false,"template":"elementor_header_footer","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[68,69,43],"tags":[59,84,67,83,82,66,80,81,85,77,78,79,64],"class_list":["post-1810","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino","category-electronics","category-tutorials","tag-arduino","tag-c","tag-complete","tag-cpp","tag-ide","tag-learn-by-doing","tag-mg995","tag-mg996r","tag-motor","tag-servo","tag-servomotor","tag-sg90","tag-tutorial"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Control a Servo Motor with Arduino - Learn by Doing!<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/learnbydoing.dev\/es\/how-to-control-a-servo-motor-with-arduino-uno\/\" \/>\n<meta property=\"og:locale\" content=\"es_ES\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Installing ROS 2 Jazzy on Ubuntu 24.04: Step-by-Step Tutorial\" \/>\n<meta property=\"og:description\" content=\"Servo motors are widely used in robotics, automation, and RC models because they can move to specific angles with precision. In this tutorial, you\u2019ll learn how to connect a servo motor to an Arduino Uno and control its position with simple code. \u00a0\ud83d\udcdd Required Components 1\u00d7 Arduino Uno 1\u00d7 Servo Motor (like SG90 or MG90S) [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/learnbydoing.dev\/es\/how-to-control-a-servo-motor-with-arduino-uno\/\" \/>\n<meta property=\"og:site_name\" content=\"Learn by Doing!\" \/>\n<meta property=\"article:published_time\" content=\"2025-06-18T10:31:05+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-01-10T22:45:01+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/06\/Progetto-senza-titolo-14.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1080\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Escrito por\" \/>\n\t<meta name=\"twitter:data1\" content=\"\" \/>\n\t<meta name=\"twitter:label2\" content=\"Tiempo de lectura\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/learnbydoing.dev\/how-to-control-a-servo-motor-with-arduino-uno\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/learnbydoing.dev\/how-to-control-a-servo-motor-with-arduino-uno\/\"},\"author\":{\"name\":\"\",\"@id\":\"\"},\"headline\":\"How to Control a Servo Motor with Arduino\",\"datePublished\":\"2025-06-18T10:31:05+00:00\",\"dateModified\":\"2026-01-10T22:45:01+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/learnbydoing.dev\/how-to-control-a-servo-motor-with-arduino-uno\/\"},\"wordCount\":378,\"publisher\":{\"@id\":\"https:\/\/learnbydoing.dev\/es\/#organization\"},\"image\":{\"@id\":\"https:\/\/learnbydoing.dev\/how-to-control-a-servo-motor-with-arduino-uno\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/06\/Servomotore-Animazione-_2_-1.webp\",\"keywords\":[\"Arduino\",\"c++\",\"complete\",\"cpp\",\"ide\",\"learn by doing\",\"mg995\",\"mg996r\",\"motor\",\"servo\",\"servomotor\",\"sg90\",\"tutorial\"],\"articleSection\":[\"Arduino\",\"Electronics\",\"Tutorials\"],\"inLanguage\":\"es\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/learnbydoing.dev\/how-to-control-a-servo-motor-with-arduino-uno\/\",\"url\":\"https:\/\/learnbydoing.dev\/how-to-control-a-servo-motor-with-arduino-uno\/\",\"name\":\"How to Control a Servo Motor with Arduino - Learn by Doing!\",\"isPartOf\":{\"@id\":\"https:\/\/learnbydoing.dev\/es\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/learnbydoing.dev\/how-to-control-a-servo-motor-with-arduino-uno\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/learnbydoing.dev\/how-to-control-a-servo-motor-with-arduino-uno\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/06\/Servomotore-Animazione-_2_-1.webp\",\"datePublished\":\"2025-06-18T10:31:05+00:00\",\"dateModified\":\"2026-01-10T22:45:01+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/learnbydoing.dev\/how-to-control-a-servo-motor-with-arduino-uno\/#breadcrumb\"},\"inLanguage\":\"es\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/learnbydoing.dev\/how-to-control-a-servo-motor-with-arduino-uno\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\/\/learnbydoing.dev\/how-to-control-a-servo-motor-with-arduino-uno\/#primaryimage\",\"url\":\"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/06\/Servomotore-Animazione-_2_-1.webp\",\"contentUrl\":\"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/06\/Servomotore-Animazione-_2_-1.webp\",\"width\":1920,\"height\":1080},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/learnbydoing.dev\/how-to-control-a-servo-motor-with-arduino-uno\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/learnbydoing.dev\/es\/learn-by-doing-es\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Control a Servo Motor with Arduino\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/learnbydoing.dev\/es\/#website\",\"url\":\"https:\/\/learnbydoing.dev\/es\/\",\"name\":\"Learn by Doing!\",\"description\":\"Learn Robotics the fun way\",\"publisher\":{\"@id\":\"https:\/\/learnbydoing.dev\/es\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/learnbydoing.dev\/es\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"es\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/learnbydoing.dev\/es\/#organization\",\"name\":\"Learn by Doing!\",\"url\":\"https:\/\/learnbydoing.dev\/es\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\/\/learnbydoing.dev\/es\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/06\/cropped-cropped-cropped-Progetto-senza-titolo-6-1.png\",\"contentUrl\":\"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/06\/cropped-cropped-cropped-Progetto-senza-titolo-6-1.png\",\"width\":512,\"height\":512,\"caption\":\"Learn by Doing!\"},\"image\":{\"@id\":\"https:\/\/learnbydoing.dev\/es\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.linkedin.com\/in\/antonio-brandi-512166bb\/\"]},{\"@type\":\"Person\",\"@id\":\"\",\"url\":\"https:\/\/learnbydoing.dev\/es\/author\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Control a Servo Motor with Arduino - Learn by Doing!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/learnbydoing.dev\/es\/how-to-control-a-servo-motor-with-arduino-uno\/","og_locale":"es_ES","og_type":"article","og_title":"Installing ROS 2 Jazzy on Ubuntu 24.04: Step-by-Step Tutorial","og_description":"Servo motors are widely used in robotics, automation, and RC models because they can move to specific angles with precision. In this tutorial, you\u2019ll learn how to connect a servo motor to an Arduino Uno and control its position with simple code. \u00a0\ud83d\udcdd Required Components 1\u00d7 Arduino Uno 1\u00d7 Servo Motor (like SG90 or MG90S) [&hellip;]","og_url":"https:\/\/learnbydoing.dev\/es\/how-to-control-a-servo-motor-with-arduino-uno\/","og_site_name":"Learn by Doing!","article_published_time":"2025-06-18T10:31:05+00:00","article_modified_time":"2026-01-10T22:45:01+00:00","og_image":[{"width":1920,"height":1080,"url":"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/06\/Progetto-senza-titolo-14.webp","type":"image\/webp"}],"twitter_card":"summary_large_image","twitter_misc":{"Escrito por":"","Tiempo de lectura":"4 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/learnbydoing.dev\/how-to-control-a-servo-motor-with-arduino-uno\/#article","isPartOf":{"@id":"https:\/\/learnbydoing.dev\/how-to-control-a-servo-motor-with-arduino-uno\/"},"author":{"name":"","@id":""},"headline":"How to Control a Servo Motor with Arduino","datePublished":"2025-06-18T10:31:05+00:00","dateModified":"2026-01-10T22:45:01+00:00","mainEntityOfPage":{"@id":"https:\/\/learnbydoing.dev\/how-to-control-a-servo-motor-with-arduino-uno\/"},"wordCount":378,"publisher":{"@id":"https:\/\/learnbydoing.dev\/es\/#organization"},"image":{"@id":"https:\/\/learnbydoing.dev\/how-to-control-a-servo-motor-with-arduino-uno\/#primaryimage"},"thumbnailUrl":"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/06\/Servomotore-Animazione-_2_-1.webp","keywords":["Arduino","c++","complete","cpp","ide","learn by doing","mg995","mg996r","motor","servo","servomotor","sg90","tutorial"],"articleSection":["Arduino","Electronics","Tutorials"],"inLanguage":"es"},{"@type":"WebPage","@id":"https:\/\/learnbydoing.dev\/how-to-control-a-servo-motor-with-arduino-uno\/","url":"https:\/\/learnbydoing.dev\/how-to-control-a-servo-motor-with-arduino-uno\/","name":"How to Control a Servo Motor with Arduino - Learn by Doing!","isPartOf":{"@id":"https:\/\/learnbydoing.dev\/es\/#website"},"primaryImageOfPage":{"@id":"https:\/\/learnbydoing.dev\/how-to-control-a-servo-motor-with-arduino-uno\/#primaryimage"},"image":{"@id":"https:\/\/learnbydoing.dev\/how-to-control-a-servo-motor-with-arduino-uno\/#primaryimage"},"thumbnailUrl":"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/06\/Servomotore-Animazione-_2_-1.webp","datePublished":"2025-06-18T10:31:05+00:00","dateModified":"2026-01-10T22:45:01+00:00","breadcrumb":{"@id":"https:\/\/learnbydoing.dev\/how-to-control-a-servo-motor-with-arduino-uno\/#breadcrumb"},"inLanguage":"es","potentialAction":[{"@type":"ReadAction","target":["https:\/\/learnbydoing.dev\/how-to-control-a-servo-motor-with-arduino-uno\/"]}]},{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/learnbydoing.dev\/how-to-control-a-servo-motor-with-arduino-uno\/#primaryimage","url":"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/06\/Servomotore-Animazione-_2_-1.webp","contentUrl":"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/06\/Servomotore-Animazione-_2_-1.webp","width":1920,"height":1080},{"@type":"BreadcrumbList","@id":"https:\/\/learnbydoing.dev\/how-to-control-a-servo-motor-with-arduino-uno\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/learnbydoing.dev\/es\/learn-by-doing-es\/"},{"@type":"ListItem","position":2,"name":"How to Control a Servo Motor with Arduino"}]},{"@type":"WebSite","@id":"https:\/\/learnbydoing.dev\/es\/#website","url":"https:\/\/learnbydoing.dev\/es\/","name":"Learn by Doing!","description":"Learn Robotics the fun way","publisher":{"@id":"https:\/\/learnbydoing.dev\/es\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/learnbydoing.dev\/es\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"es"},{"@type":"Organization","@id":"https:\/\/learnbydoing.dev\/es\/#organization","name":"Learn by Doing!","url":"https:\/\/learnbydoing.dev\/es\/","logo":{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/learnbydoing.dev\/es\/#\/schema\/logo\/image\/","url":"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/06\/cropped-cropped-cropped-Progetto-senza-titolo-6-1.png","contentUrl":"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/06\/cropped-cropped-cropped-Progetto-senza-titolo-6-1.png","width":512,"height":512,"caption":"Learn by Doing!"},"image":{"@id":"https:\/\/learnbydoing.dev\/es\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.linkedin.com\/in\/antonio-brandi-512166bb\/"]},{"@type":"Person","@id":"","url":"https:\/\/learnbydoing.dev\/es\/author\/"}]}},"_links":{"self":[{"href":"https:\/\/learnbydoing.dev\/es\/wp-json\/wp\/v2\/posts\/1810","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/learnbydoing.dev\/es\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/learnbydoing.dev\/es\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/learnbydoing.dev\/es\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/learnbydoing.dev\/es\/wp-json\/wp\/v2\/comments?post=1810"}],"version-history":[{"count":41,"href":"https:\/\/learnbydoing.dev\/es\/wp-json\/wp\/v2\/posts\/1810\/revisions"}],"predecessor-version":[{"id":5625,"href":"https:\/\/learnbydoing.dev\/es\/wp-json\/wp\/v2\/posts\/1810\/revisions\/5625"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/learnbydoing.dev\/es\/wp-json\/wp\/v2\/media\/2084"}],"wp:attachment":[{"href":"https:\/\/learnbydoing.dev\/es\/wp-json\/wp\/v2\/media?parent=1810"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/learnbydoing.dev\/es\/wp-json\/wp\/v2\/categories?post=1810"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/learnbydoing.dev\/es\/wp-json\/wp\/v2\/tags?post=1810"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}