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

Arduino UNO Controlled Servo Motor

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

Circuit Documentation

Summary of the Circuit

This circuit consists of an Arduino UNO microcontroller, a servo motor compatible with Wokwi, and a photodiode. The Arduino UNO is used as the central processing unit to control the servo motor based on the program loaded into it. The servo motor is powered by the 5V output from the Arduino and receives pulse-width modulation (PWM) signals on one of the digital pins (D9) to control its position. The photodiode is included in the parts list but is not connected in the current configuration of the circuit.

Component List

Arduino UNO

Photodiode

Servo (Wokwi Compatible)

Resistor

Wiring Details

Arduino UNO

Servo (Wokwi Compatible)

Documented Code

#include <Servo.h>  // Standard Arduino Servo library

Servo myservo;  // Servo object
int servopin = 9;  // Pin where the servo is connected
int servopos = 0;  // Initial servo position

void setup() {
    Serial.begin(9600);  // Initialize serial communication
    myservo.attach(servopin);  // Attach the servo to pin 9
}

void loop() {
    myservo.write(servopos);  // Move the servo to the position
    delay(1000);  // Delay for 1 second

    // Increment the servo position
    servopos += 10;  // Increase position by 10 degrees
    if (servopos > 180) {
        servopos = 0;  // Reset position to 0 if it exceeds 180
    }
}

File Name: sketch.ino

Description: This code initializes a servo motor on pin 9 of the Arduino UNO. It sets up the servo to start at position 0 and then moves it in increments of 10 degrees every second. Once the servo reaches a position greater than 180 degrees, it resets back to 0 degrees.