15 Nov 2016

Fun with LDRs

The easiest way to give your robot some life | Cool things to do with a LDR

The easiest and cheapest way to make your robots sense the environment is by giving them ability to feel light using LDRs ( Light Dependent Resitance ). LDRs are one of the cheapest and most effective sensors out there in the market that opens up endless possibilities towards autonomous and itelligent robotics.

This article briefs out a few cool things I tried with LDRs.

What is a LDR ?

LDR (Light Dependent Resistance) is a variable resistance whose resistance changes according to the intensity of the light falling on it. The relationship between the resistance $ \mathbf{R}_{L} $ and light intensity Lux for a typical LDR is :

$$ \mathbf{R}_{L} = {500 \over Lux} \ $$


Using this light sensitive resistance to optimize power consumption and increase effectiveness led to the design and development of an intelligent pair of bicycle indicators. These indicators were capable of adjusting the power consumption and hence brightness depending on the intensity of light incident on them.


Switching cirtcuits

Transistors can be used with LDRs to design threshold switches. Much of my work from 2013 involved transistors and LDRs. For example the automated curtains which fold up as the sun rises and unfolds on sunset uses such circut design.

A more interesting use case is the design a light following robot with two trigger circuits.


However such circuits tend to fail frequently depending on various environmental conditions. Call for the microcontrollers.

Reading LDRs with Arduino

Reading the analog value from a LDR using arduino is very easy.

const int ldrPin = A0;

void setup() {
	pinMode(ldrPin, INPUT);
	Serial.begin(9600);
}

void loop() {
	int ldrVal = analogRead(ldrPin);
	Serial.println(ldrVal);
}
// prints the analog value (0,1023) from LDR

Enclosing the LDR with a LED allows threshold based color detection, obstacle avoidance etc.

With multiple LDRs one can build line following robots, light following robots and many more.