LDR Project Repoert
LDR Project Repoert
OF THE REQUIREMENTS
FOR THE AWARD OF THE DEGREE OF
BACHELOR OF TECHNOLOGY
IN
ELECTRONICS AND COMMUNICATION ENGINEERING
LDR CAMERA
SUBMITTED TO:
Dr. MUKUL SARKAR
ASST. PROF.
EE, IIT DELHI
SUBMITTED BY:
IKJOT SINGH 00696402813
Maharaja Agrasen Institute of
Technology, New Delhi
CERTIFICATE
ACKNOWLEDGEMENT
It is often said that life is a mixture of achievements, failures, experiences, exposures and efforts to
make your dream come true. There are people around you who help you realize your dream. I
acquire this opportunity with much pleasure to acknowledge the invaluable assistance of Indian
Institute of Technology and all the people who have helped me through the course of my journey in
successful completion of this project.
I would like to articulate my gratitude and appreciation to my project guide Dr. Mukul Sarkar
Who has always been a constant motivation and guiding factor throughout the project time in and
out as well. It has been a great pleasure for me to get an opportunity to work under his guidance and
complete the project successfully. I express my thanks to Miss. Chandani Anand, Phd Scholar,
IITD for her kind cooperation during the period of my summer internship.
I am grateful to my friends who gave me the moral support in my times of difficulties. Last but not
the least I would like to express my special thanks to my family for their continuous motivation and
support.
Ikjot Singh
(00696402813)
Abstract
Now-a-days cameras are widely used in robots to understand gestures of an object or during
navigation. A simple non-conventional image sensor made with photoresistors and diodes is
presented for taking gestures of an object as input. The single pixel of the designed image sensor is
done with a LDR (Light Dependent Resistor) and a diode. Output of this device is fed to the
MATLAB and actions are triggered according to the program written in MATLAB by taking image
as an input. The image sensor consists of an array of 10 x 10 pixels and occupies an area of 7 x 7
cm2. The image sensor is designed and fabricated on a dotted PCB. Arduino Mega 2560 is used for
analog to digital conversion of the obtained signal. Captured image is viewed and processed in
MATLAB. The clear 10 x 10 pixels grayscale image was viewed after completion of this project.
INDEX
Certificate
Acknowledgement
Abstract
List of Figures
List of Photographs
1. INTRODUCTION
1.1. Objective
1.2.Prerequisites
1.2.1.
Light Dependent Resistor (LDR)
1.2.2.
Arduino
1.2.3.
MATLAB
2. PRINCIPLE CONCEPT AND WORKING
2.1.Concept of Digital Images
2.2.Characteristics of LDR
2.3.Working Concept of project
2.4.Elemental circuit and Prototype circuit
3. BUILDING THE PROJECT
3.1.Software
3.1.1.
Interfacing MATLAB with Arduino
3.1.2.
Commands used in MATLAB
3.1.3.
Code Algorithm
3.2.Hardware
3.2.1.
Hardware required and their description
3.2.2.
Soldering
3.2.3.
Steps for making the hardware
3.2.4.
Testing
3.2.5.
Precautions
Results
Conclusion
References
i
ii
iii
iv
v
List of Figure
S.NO.
FIGURE
FIGURE DESCRIPTION
NO.
PAGE
NO.
1.1
1.2
2.1
2.2
2.3
2.4
2.5
Elemental Circuit
2.6
4.1(a)-(f)
List of Photographs
S.N
PHOTOGRAP
H NO.
1.1
Commercial LDR
3.1
3.2(a)
NO.
dotted PCB
4
3.2(b)
3.3
3.4
3.5
4.1
CHAPTER: 1 INTRODUCTION
1.1 Objective
The main objective this project is to design an image sensor using photoresistors and to
acquire the captured image in the computer for further processing. The processed image can
be linked with a software for giving inputs to operating system. By achieving this device one
can control his computer by gestures.
1.2 Prerequisites
This project is the assemblage of the study of some devices and software which must be
known by a person working on this project. Basic element used in this project is Photo
resistor or light-dependent resistor (LDR), for controlling and operation of hardware
ARDUINO is used. To store the image and process it, a computer software is required, for
this project MATLAB has been used. A basic introduction to these topics is covered in
following topics.
resistor (LDR)
or photocell is
light-controlled
variable resistor. The resistance of a photoresistor decreases with increasing incident light
intensity; in other words, it exhibits photoconductivity. A photoresistor can be applied in
light-sensitive detector circuits, and light- and dark-activated switching circuits.
A photoresistor is made of a high resistance semiconductor. In the dark, a photoresistor can
have a resistance as high as several megohms (M), while in the light, a photoresistor can
have a resistance as low as a few hundred ohms. If incident light on a photoresistor exceeds
a certain frequency, photons absorbed by the semiconductor give bound electrons enough
energy to
jump
into
the conduction
band. The
resulting
free
electrons
(and
their hole partners) conduct electricity, thereby lowering resistance. The resistance range and
sensitivity of a photoresistor can substantially differ among dissimilar devices. Moreover,
Figure 1.1-Photoresistor
symbol
1.2.2 Arduino
Arduino is an open-source prototyping platform based on easy-to-use hardware and
software. Arduino boards are able to read inputs - light on a sensor, a finger on a button, or a
Twitter message - and turn it into an output - activating a motor, turning on an LED, publishing
something online. You can tell your board what to do by sending a set of instructions to the
microcontroller on the board. To do so you use the Arduino programming language (based on
Wiring), and the Arduino Software (IDE), based on Processing.
Over the years Arduino has been the brain of thousands of projects, from everyday objects to
complex scientific instruments. A worldwide community of makers - students, hobbyists, artists,
programmers, and professionals - has gathered around this open-source platform, their
contributions have added up to an incredible amount of accessible knowledge that can be of great
help to novices and experts alike.
Arduino was born at the Ivrea Interaction Design Institute as an easy tool for fast prototyping,
aimed at students without a background in electronics and programming. As soon as it reached a
wider community, the Arduino board started changing to adapt to new needs and challenges,
differentiating its offer from simple 8-bit boards to products for IoT applications, wearable, 3D
printing, and embedded environments. All Arduino boards are completely open-source,
empowering users to build them independently and eventually adapt them to their particular
needs. The software, too, is open-source, and it is growing through the contributions of users
worldwide.
1.2.3 MATLAB
The tutorials are independent of the rest of the document. The primarily objective is to help you
learn quickly the first steps. The emphasis here is learning by doing. Therefore, the best way to
learn is by trying it yourself. Working through the examples will give you a feel for the way that
MATLAB operates. In this introduction we will describe how MATLAB handles simple
numerical expressions and mathematical formulas. The name MATLAB stands for MATRIX
LABORATORY. MATLAB was written originally to provide easy access to matrix software
developed by the LINPACK (linear system package) and EISPACK (Eigen system package)
projects. MATLAB [1] is a high-performance language for technical computing. It integrates
computation, visualization, and programming environment. Furthermore, MATLAB is a modern
programming language environment: it has sophisticated data structures, contains built-in editing
and debugging tools, and supports object-oriented programming. These factors make MATLAB
an excellent tool for teaching and research. MATLAB has many advantages compared to
conventional computer languages (e.g., C, FORTRAN) for solving technical problems.
MATLAB is an interactive system whose basic data element is an array that does not require
dimensioning. The software package has been commercially available since 1984 and is now
considered as a standard tool at most universities and industries worldwide. It has powerful builtin routines that enable a very wide variety of computations. It also has easy to use graphics
commands that make the visualization of results immediately available. Specific applications are
collected in packages referred to as toolbox. There are toolboxes for signal processing, symbolic
computation, control theory, simulation, optimization, and several other fields of applied science
and engineering.
Binary Images
In a binary image, each pixel assumes one of only two discrete values: 1 or 0. A binary image is
stored as a logical array. By convention, this documentation uses the variable name BW to refer
to binary images.
The following figure shows a binary image with a close-up view of some of the pixel values.
Grayscale Images
A digital image is a numeric representation (normally binary) of a two-dimensional image.
Depending on whether the image resolution is fixed, it may be of vector or raster type. By itself,
the term "digital image" usually refers to raster images or bitmapped images.
An image can be of class uint8, uint16, single, or double. Each pixel color is of a value between
0 and 1 as depicted below. A pixel whose pixel color is 0 is displayed as black, and a pixel whose
color components pixel color is 1 is displayed as white.
However, to simplify our task specially when it comes to serial communication we decided to
use
an
Arduino
in place
of
the
ADC.
Arduino
sends
the data
received
from the
LDR
matrix
serially
to
the
Next is the circuit diagram that we used for designing the circuit for our LDR Camera. For sake
of simplicity we initially considered only a 3 x 3 matrix. The multiplexing used here is very
similar to LED multiplexing.
Figure 2.6Figure
Prototype
2.5- Elemental
Circuit of circuit
LDR Multiplexing
When a particular column is set high and a particular row goes low, the circuit is completed for
the LDR present at their intersection. All the rest columns are kept low and similarly all the rest
rows are kept high. Any other LDR other than the selected one will be open circuited because the
corresponding diode will be reverse biased. All these column and rows pins are connected to the
DIGITAL PINS of Arduino. The reading across the 10 K resistor is taken by the ANALOG PIN
of Arduino as shown in figure.
Now one can extend this circuit to a MxN matrix (here in this project 10x10 matrix have been
used).
Why Using of Diodes with LDR?
During making this project firstly a matrix of LDR without Diodes were made, when it was
connected and run by the Arduino and MATLAB, no output was shown. Then after searching for
the problem this was found that all the resistors in the matrix were being activated
simultaneously as they were all connected to each other. But for this project to properly only one
LDR must be activated at instance. So this problem was resolved by soldering a Diode with each
LDR. After this when the multiplexing code was run, outputs were shown as expected.
3.1 Software
3.1.1 Interfacing MATLAB with Arduino
Arduino Support from MATLAB
MATLAB Support Package for Arduino hardware enables to use MATLAB to communicate with
the Arduino board over a USB cable. This package is based on a server program running on the
board, which listens to commands arriving via serial port, executes the commands, and, if
needed, returns a result. This approach helps in:
Interactively develop programs to acquire analog and digital data, and to control DC, servo,
and stepper motors.
This support package helps to make an object in MATLAB which will communicate with
Arduino.
During the creation of this object MATLAB writes a control code on Arduino, which transfers
the control of all the Arduino Digital and Analog pins to the MATLAB. MATLAB execute single
operation on Arduino in one cycle which reduces its speed.
Clear all- It will clear all the variable in the workspace of MATLAB
pic = zeros(m,n)
It will create mxn matrix with all values 0 and stores it in variable pic.
Commands related to Arduino object
These commands are case sensitive.
arduino
It creates a connection to unofficial (clone) Arduino hardware on the specified port and
enables users to operate Arduino through MATLAB by this object.
Syntax-
pinMode
This will define the mode for the specified arduino pin and sets it as INPUT or
OUTPUT
SyntaxpinMode(a,pin,mode);
here a is the Arduino object made in MATLAB.
Example-
pinMode(a,3,output);
this will set the mode of the 3rd pin as output.
digitalWrite
This will set the value of the digital pin as high or low i.e. 1 or 0.
SyntaxdigitalWrite(a,pin,value);
here value can be 1 or 0.
ExampledigitalWrite(a,15,1);
this will set the 15th pin as high.
analogRead
This command will read the analog value that is present on the specified analog pin and
and is mapped into 0-1024. This commands returns the value so a variable must be
needed to store that value.
SyntaxVariable= analogRead(a,pin);
ExampleVal= analogRead(a,3);
This will read a value from the third analog pin of the Arduino and store it to the variable
val in MATLAB.
pause
It is used to give delay between commands or stops the execution temporarily.
Syntax-
pause(n)
mat2gray
It converts the matrix A to the intensity image I. The returned matrix I contains values in
the range 0.0 (black) to 1.0 (full intensity or white).
Syntax-
I = mat2gray(A)
imshow
It displays the image I in a Handle Graphics figure, where I is a grayscale, RGB
(truecolor), or binary image. For binary images, imshow displays pixels with the
value 0 (zero) as black and 1 as white
Syntax-
imshow(I)
imtool
It will display the image I in Image viewer app windows in which various functions are
provided to make changes in the image.
2. Define all the pin modes of pins from 26 to 45 as output and set all the even pins as
1 and all the odd pins as 0 between 26 and 45 (here even pins are columns and odd
pins are rows).
6. Set the row pin(2*k+1) as 1 and read the analog value from analog pin(k-13) and
store it into 3D matrix.
3.2 Hardware
3.2.2 Soldering
Basic Soldering Guide
1. Make sure soldering iron tip is clean and tinned with solder.
2. Heat the pad and component legs with tip of the iron simultaneously, be careful not to
burn the printed circuit board or any plastic or insulation.
3. Whilst the iron is still in contact with the area, apply a small amount of solder to the
join, hold the iron on until the solder flows properly.
4. Check to make sure the solder joint is nice and shiny and that it does not bridge any
connections.
5. Clean off the soldering iron and tin the tip, try to keep the tip well tinned with a nice
shiny layer of solder at all times.
Soldering Tips
1. Take your time and try to not add too much solder to the joints.
2. If you apply too much solder to a join, it can be removed by heating the solder till it is
liquid again, then the excess can be sucked off using a solder sucker.
3. Use sticky tac to hold the circuit board or components in place whilst soldering, this
will free up your hands and make the process much easier.
4. If at any point you feel the iron has been held on the circuit board or a component for
too long, remove the iron immediately and let the area cool down before continuing, over
heating the board or components can damage them irreparably.
5. Dull or dry joints can be easily repaired by re-flowing the solder.
6. Using the wire clippers to remove hardened solder can damage connections and can
de-laminate the metal from the substrate.
7. After soldering there can be excess flux on the board and around the soldering joints,
cleaning this off with a toothbrush and rubbing alcohol can help to protect the joints from
corrosion.
8. If you're having trouble with the solder spool sticking to the joint, remember to heat
the soldering area first, then apply the solder, remove the solder from the area, then
remove the iron from the area.
Photograph 3.2(a)
Photograph 3.2(b)
2. Now bend the pins as shown in figure and solder it to the next consecutive pin in a
row.
Photograph 3.3
3. After soldering the pins along a row, now solder the diodes to the other left pins of
LDR that are still erect. (here I have soldered the diodes after placing them so that a
single pixel acquires smallest area).
4. Now repeat the above steps for each row and you will leave with 100 diodes pins
erected in the back side of the LDR matrix.
5. Now start soldering column wise such that all the pins in a column are connected
together.
6. The final device after completing soldering will appear like the following images. The
open ends are further connected to the bug strips in order to ease attachments.
3.3.3 Testing
Testing is the important part in making a hardware with correct connections. While
soldering one must continuously check the consecutive connections by multimeter
selected in buzzer mode. Test the circuit after soldering each row separately so that bugs
can be found there only.
3.3.4 Precautions
Be careful to keep clothes, hair, power cables and skin etc. away from the soldering
iron tip and the metal shaft.
Be careful when returning the iron to its stand, make sure it is secure and does not
fall off.
Point the circuit away from yourself and others whilst trimming down component
legs, and be careful of any sharp bits of metal whilst handling the circuit or
components.
RESULT
Final Fabricated Hardware
This is the final fabricated hardware of this project. Photograph 4.1 shows the LDR matrix
connected with the Arduino Mega 2560 with connecting wires. There is a USB Connectivity
from Arduino which can be connected to computer in order to communicate with MATLAB.
Left Top
Left Bottom
Left Bottom
Figure4.1 (a)
Left Bottom
Left Top
Figure
Left Top
4.1 (e)
Figure
Left Bottom
4.1 (f)
Left Bottom
Figure 4.1 (a), (b), (c), (d), (e), (f) are the output MATLAB Figures that are captured by the LDR
camera.
CONCLUSION
A simple non-conventional image sensor was fabricated using photoresistors and diodes on a
puff board. The single pixel includes a LDR and Diode in series. The image sensor consists of an
array of 10 x 10 pixels and occupies an area of 7 x 7 cm2. The image sensor was designed and
fabricated on a dotted PCB. The clear 10 x 10 pixel grayscale image was viewed in result of this
project. Future work of this project will be focused on the gestural input through LDR camera.
Work will be carried on by first increasing its speed by making a hardwired chip and will try to
reduce the power consumption of this project.
REFERENCES
1. http://www.instructables.com/id/Tutorial-6-MATLAB-andArduinopart-1-up-and-run/
2. http://in.mathworks.com/matlabcentral/fileexchange/47605creating-amotion-detector-using-an-arduino--a-photoresistorandmatlab/content/html/Photoresistor_Motion_Detection_Article.ht
ml Figure-2 of our documentation was taken from this link.
3. Digital Image Processing (English) 3rd Edition Author : Richard
E Woods, Rafael C Gonzalez Publisher : Pearson ISBN-10 :
8131726959
4. Digital Image Processing using Matlab Author : Richard E
Woods, Rafael C Gonzalez,Steven L. Eddins Publisher : McGraw
Hill Education (India) Private Limited ISBN-10 : 0070702624
5.http://www.nfiautomation.org/FREE_Download/Technical
%20Documents/Arduino/30%20arduino%20projects%20for
%20the%20evil%20genius. pdf