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

Arduino UNO Controlled LED Blink and Servo Motor Movement

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

Circuit Documentation

Summary

This circuit is designed around an Arduino UNO microcontroller and includes a red two-pin LED, a resistor, and a servo motor. The LED is controlled by one of the digital pins on the Arduino and is connected in series with a resistor to limit the current. The servo motor is controlled by another digital pin and is powered directly from the Arduino's voltage supply pins. The microcontroller runs a program that turns the LED on and off and moves the servo between two positions.

Component List

Arduino UNO

Resistor

LED: Two Pin (red)

Servo

Wiring Details

Arduino UNO

Resistor

LED: Two Pin (red)

Servo

Documented Code

#include <Servo.h>

// Pin Definitions
const int ledPin = 9;    // Pin for the LED
const int servoPin = 6;  // Pin for the servo

Servo myServo;

void setup() {
  // Initialize the LED pin
  pinMode(ledPin, OUTPUT);
  
  // Initialize the servo
  myServo.attach(servoPin);
  
  // Move servo to initial position (0 degrees)
  myServo.write(0);
}

void loop() {
  // Turn on the LED
  digitalWrite(ledPin, HIGH);
  delay(5000); // LED ON for 5 seconds
  
  // Turn off the LED
  digitalWrite(ledPin, LOW);
  
  // Move servo to 180 degrees
  myServo.write(180); // Move to 180 degrees
  delay(40000); // Wait for 40 seconds
  
  // Move servo back to initial position (0 degrees)
  myServo.write(0); // Move back to 0 degrees
  
  // Optional delay before starting the next cycle
  delay(1000); // Wait for 1 second before repeating
}

Filename: sketch.ino

This code is designed to control an LED and a servo motor using an Arduino UNO. The LED is turned on for 5 seconds and then turned off. Meanwhile, the servo motor moves to 180 degrees, waits for 40 seconds, and then returns to 0 degrees. This cycle repeats indefinitely.