13
Author:- IKJOT SINGH MOHIT LAMBA LDR CAMERA A non conventional design This is a low budget device. Use it as a camera, use it as a touchpad or simply control your computer with your gestures.It can be used as one like .

gesture

Embed Size (px)

Citation preview

Author:-

IKJOT SINGH

MOHIT LAMBA

LDR CAMERA A non conventional design

This is a low budget device. Use it as a camera, use it as a

touchpad or simply control your computer with your gestures.It

can be used as one like .

LDR CAMERA 1

Motivation

A WORKSHOP AT IIT DELHI

On 12th January 2015, both of us attended a workshop in IIT Delhi, organized by

Texas instruments (TI) in Bharti building under Dr. C. P. Ravikumar .there one of the presenter Mr. Mukul Bhanwar showed us, how a conventional

camera pixel is designed and fabricated by using diodes and other components.

He then went on to show us his first camera that he himself has designed in TI,

which was of 128x128 matrix of such pixels. We were simply amazed.

A SEMINAR IN OUR OWN COLLEGE

Back in our college, one month later, I was taking a seminar on ‘Digital Image

Processing (DIP)’ under IEEE. While demonstrating of how powerful tool

MATLAB is in DIP, especially its power of converting matrices into images and

vice versa, one of the student, IKJOT SINGH came up with a very bizarre idea.

IKJOT SINGH recalled that one can vary easily the voltage in a circuit as a

function of intensity of light falling on it, simply with the help of a Light Dependent

Resistor (LDR). He further argued if we take a matrix of LDR ( a similar thing that

has been done by Mukul Sir in IIT Delhi) then the values returned by each LDR

in that matrix can be treated as a pixel value of an image.

LDR CAMERA 2

The Concept

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. The setup of our project is as follows. In between a light source and an object there will be a LDR matrix. This LDR should be as big as possible for best results. However for our experimentation we have restricted it to a 10x10 matrix. Now the voltage developed across each LDR is fed to an Analog to Digital Convertor (ADC). This ADC is further connected to a computer, via shift register, so that the MATLAB can use these values. However to simplify our task specially when it comes to serial communication we decided to use an Arduino in place of the ADC.

LDR CAMERA 3

Figure 1: Concept Diagram

LDR CAMERA 4

Hardware Required

Following hardware is required:-

LDR (100 pc)

1N4007 Diodes (100 pc)

Dotted PCB (1)

Arduino (1)

Bug strips

Connecting wire

Bug strips connectors

Soldering Iron and Soldering wires

Figure 2: Hardware Required

LDR CAMERA 5

Circuit Diagram

Following is the circuit taken from Mathworks documentation, a link to this has been given in the references. Here a 5V supply is used to power the circuit. Now as light intensity falling on the LDR varies the resistance of the LDR varies. This variation in LDR resistance causes a change in voltage drop across the 10 KΩ resistor. Now this voltage difference is read by ADC. Now to simplify our task especially to do away with the serial communication problem, we decided to use an Arduino instead. Arduino has a predefined library file for interfacing with MATLAB. A link to learn this interfacing has also been provided in the references.

Figure 3: Test Circuit

LDR CAMERA 6

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.

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 column 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 we have used a 10x10 matrix).

Figure 4: Prototype Circuit

LDR CAMERA 7

Finished device

Figure 5: Front side view

Figure 6: Back side view

LDR CAMERA 8

Figure 7: Complete circuit

LDR CAMERA 9

Testing

After making this hardware we just wanted to test the variations across a single

LDR just to check our connections. In this code we are not Multiplexing the

entire matrix but just concentrating on a single LDR. This is our code in MATLAB

for testing.

This code was repeated arbitrarily for 5 to 6 LDR in our matrix.

clc clear all

a= arduno('COM5'); %creating arduino object in matlab

pinMode(a,41,'output'); %column pin pinMode(a,40,'output'); %row pin pinMode(a,3,'input'); %analog read

pin digitalWrite(a,41,1); %column pin set

high digitalWrite(a,40,0); %row pin set

low

i=0; while(i<20) val=analogRead(a,3); val pause(.5) end

LDR CAMERA 10

Code

Here is our actual code for the device.

clc;

clear all;

a=arduino('COM3')

for k=13:22

pinMode(a,2*k,'OUTPUT');

digitalWrite(a,2*k,1);

pinMode(a,(2*k+1),'OUTPUT');

digitalWrite(a,(2*k+1),0);

end

pic=zeros(10,10);

for i=1:30

val(:,:,i)=zeros(10,10);

count=1;

for k=13:22

digitalWrite(a,2*k,0);

for j=13:22

digitalWrite(a,(2*j+1),1);

pic(count)=analogRead(a,k-13);

count=count+1;

digitalWrite(a,(2*j+1),0);

end

digitalWrite(a,2*k,1);

end

pic'

pic=mat2gray(pic');

val(:,:,i)=pic;

figure(i),imshow(val(:,:,i));

end

LDR CAMERA 11

In the following video we were moving our thumb over the LDR matrix. As we

moved our thumb following is the sequence of images captured by MATLAB

using the LDR matrix.

LDR CAMERA 12

References

1. To learn how to interface MATLAB and Arduino we referred this link.

http://www.instructables.com/id/Tutorial-6-MATLAB-and-Arduino-

part-1-up-and-run/

2. To learn how a single LDR is interfaced with MATLAB, refer to this link.

http://in.mathworks.com/matlabcentral/fileexchange/47605-creating-a-

motion-detector-using-an-arduino--a-photoresistor-and-

matlab/content/html/Photoresistor_Motion_Detection_Article.html

Figure-2 of our documentation was taken from this link.

3. For learning Digital Image Processing refer to the following books

a. Title : Digital Image Processing (English) 3rd Edition

Author : Richard E Woods, Rafael C Gonzalez

Publisher : Pearson

ISBN-10 : 8131726959

b. Title : 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

4. To learn Arduino refer to this ebook

http://www.nfiautomation.org/FREE_Download/Technical%20Documen

ts/Arduino/30%20arduino%20projects%20for%20the%20evil%20genius.

pdf