0% found this document useful (0 votes)
36 views7 pages

Rehmat Ali - REG NO#2018391: Submission Date

The document describes a project that uses a servo motor to control lights based on light levels detected by a photoresistor. The key components are an Arduino board, servo motor, photoresistor, resistor, and jumper wires. The photoresistor detects light levels and the Arduino maps these values to control the angle of the servo motor in order to actuate light switches. The code reads the photoresistor input, maps it to a value between 0 and 180 degrees, and uses this to set the servo position. When light levels increase, the servo angle increases, and when light decreases, the angle decreases.

Uploaded by

Rehmat Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views7 pages

Rehmat Ali - REG NO#2018391: Submission Date

The document describes a project that uses a servo motor to control lights based on light levels detected by a photoresistor. The key components are an Arduino board, servo motor, photoresistor, resistor, and jumper wires. The photoresistor detects light levels and the Arduino maps these values to control the angle of the servo motor in order to actuate light switches. The code reads the photoresistor input, maps it to a value between 0 and 180 degrees, and uses this to set the servo position. When light levels increase, the servo angle increases, and when light decreases, the angle decreases.

Uploaded by

Rehmat Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

ES314-L

(MICROCONTROLLER AND
INTERFACING LAB)

OPEN ENDED LAB REPORT

REHMAT ALI
------------------------
REG NO#2018391
Submitted to :

Engr. Muhammad Zain

Submission
date
December 14,2020
Introduction
Servos are very versatile motors; they can be used in a wide range of mechanical applications. This project
focuses on the control of a servo motor depending on the light levels in the current environment. This idea can
be applied to applications such as control of lamps and light switches where the servo will manually actuate the
light switches given a certain light condition to both turn it on or off. This allows many homes be semi-
automated without having to a large expense. Servo motors can be used virtually anywhere and this technology
can be further applied to other fields and use cases.

Required Component
There are following components that required for this project are given below.

• Arduino 101 or Arduino Uno

• Breadboard

• Photoresistor or LDR

• 10k Ω resistor

• Servo motor

• Jumper Wires

Arduino Uno

Arduino is an open-source platform used for building electronics projects. Arduino consists of both a physical
programmable circuit board (often referred to as a microcontroller) and a piece of software, or IDE (Integrated
Development Environment) that runs on your computer, used to write and upload computer code to the physical
board.
The Arduino platform has become quite popular with people just starting out with electronics, and for good
reason. Unlike most previous programmable circuit boards, the Arduino does not need a separate piece of
hardware (called a programmer) in order to load new code onto the board -- you can simply use a USB cable.
Additionally, the Arduino IDE uses a simplified version of C++, making it easier to learn to program. Finally,
Arduino provides a standard form factor that breaks out the functions of the micro-controller into a more
accessible package.

Figure 1
Servo Motor
A servomotor is a rotary actuator or linear actuator that allows for precise control of angular or linear position,
velocity and acceleration.[1] It consists of a suitable motor coupled to a sensor for position feedback. It also
requires a relatively sophisticated controller, often a dedicated module designed specifically for use with
servomotors.
Servomotors are not a specific class of motor, although the term servomotor is often used to refer to a motor
suitable for use in a closed-loop control system.
Servomotors are used in applications such as robotics, CNC machinery or automated manufacturing.

Figure 2

Photosensor or LDR
Light dependent resistors, LDRs or photoresistors are often used in electronic circuit designs where it is necessary to
detect the presence or the level of light. These electronic components can be described by a variety of names from
light dependent resistor, LDR, photoresistor, or even photo cell, photocell or photoconductor. Although other electronic
components such as photodiodes or photo-transistor can also be used, LDRs or photo-resistors are a particularly
convenient to use in many electronic circuit designs. They provide large change in resistance for changes in light
level.

In view of their low cost, ease of manufacture, and their ease of use, LDRs have been used in a variety of different
applications. At one time LDRs were used in photographic light meters, and even now they are still used in a variety
of applications where it is necessary to detect light levels. Light dependent resistors are widely available:- they are
normally stocked by electronic component distributors, and in view of the way the electronics industry supply chain
operates these days, this is the normal way to obtain them. Electronic component distributors large and small will
typically have a good selection
Figure 3

Working principle
Connect the Arduino power to the breadboard and from breadboard to LDR and Servo as shown in Figure 4
The LDR will be getting power from the 5V pin of the Arduino, while the servo will be getting power form the
5V pin of the Arduino and both are connected to a common Ground and a 5v rail of breadboard. The angle of
servo is controlled by the mapped values also known as PWM of LDR. when the light intensity increases the
angle increases and when the intensity decreases the angle of servo starts decreasing.
Connect the 5V red rail of breadboard to the red pin of the servo with a male-to-male red jumper cable. Red
pins will be used to indicate 5V.
Connect the GND pin of the Arduino to the black power rail of the breadboard then attach servo with a male-
to-male black jumper cable.
Connect one terminal of LDR in series with 10KΩ resistor and ground. Attach the second terminal of LDR
with 5V.
Connect the 5V pin of the Arduino to the red power rail of the breadboard with a red jumper wire.
Connect the GND pin of the Arduino to the ground power rail of the breadboard with a black jumper wire.
Connect A0 pin of Arduino to the one terminal of LDR with yellow male to male jumper wire.
Connect digital pin 3 of Arduino to the signal pin of Servo using blue male to male jumper wire.

Figure 4
Code
#include <Servo.h>

Servo myservo;

int LDRpin =A0;

int datain;

int value;

void setup() {

// put your setup code here, to run once:

myservo.attach(9);

Serial.begin(119600);

void loop() {

// put your main code here, to run repeatedly:

datain = analogRead(LDRpin);

value = map(datain, 0,1023, 0, 180);

Serial.println("The Original Value of the LDR is: ");

Serial.println(datain);

Serial.println("The mapped Value of the LDR is: ");

Serial.println(value);

myservo.write(value);

delay(1000);

Output
Output as shown in figure 5

Figure 5
CLASS NAME

Lesson Notebook

IN THIS SECTION:

• List your contents here

• List your contents here

• List your contents here

• List your contents here

Tab 5

You might also like