Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Servo Motor Controller

View and Edit Project In Cirkit DesignerImage of Arduino UNO Servo Motor Controller

Circuit Documentation

Summary of the Circuit

This circuit consists of an Arduino UNO microcontroller board that is used to control a servo motor. The servo motor is connected to the Arduino UNO via three connections: power (5V), ground (GND), and control signal (pulse). The control signal is provided through one of the digital I/O pins of the Arduino UNO (pin D9). The Arduino UNO is programmed to move the servo motor smoothly between 0 and 180 degrees, creating a sweeping motion.

Component List

Arduino UNO

Servo Motor

Wiring Details

Arduino UNO

Servo Motor

Documented Code

/*
 * This Arduino sketch controls a servo motor connected to pin D9 of an Arduino UNO.
 * The servo will smoothly move between its open and closed positions.
 */

#include <Servo.h>

Servo myServo;  // create servo object to control a servo

void setup() {
  myServo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop() {

  // Move servo from 0 to 180 degrees
  for (int pos = 0; pos <= 180; pos += 1) {
    myServo.write(pos);  // move servo to 'pos' degrees
    delay(15);           // wait for 15 milliseconds to create a smooth motion
  }

  // Move servo from 180 to 0 degrees
  for (int pos = 180; pos >= 0; pos -= 1) {
    myServo.write(pos);  // move servo to 'pos' degrees
    delay(15);           // wait for 15 milliseconds to create a smooth motion
  }
}

Filename: sketch.ino

Description: The code defines the behavior of the servo motor connected to the Arduino UNO. It includes the Servo library and defines a Servo object named myServo. In the setup() function, the servo motor is attached to digital pin 9. The loop() function contains two for loops that move the servo motor from 0 to 180 degrees and back, with a 15-millisecond delay between each degree to create a smooth motion.