Monday, October 31, 2011

Light (CIRC-09)

PURPOSE:

To turn a LED on using a Photo Resistor (light based resistance). 

EQUIPMENT:

·         1 x Photo-Resistor
·         1 x Yellow LED
·         1 x 10k Ohm Resistor
·         1 x 330 Ohm Resistor
·         1 x CIRC-09 Breadboard Sheet
·         6 x Wire (any colour)

PROGRAM DETAILS:

A Photo Resistor (Image Link)

The new part introduced in this program is called the photo resistor which is a light based resistance. Photo resistor is a device that produces a variable resistance dependant on the on the amount of incident light. It has 2 leads and it looks like a little disk with a transparent top and a curvy line underneath. They are good for environmentally controlled experiments. The principles we use for a photo resistor is same as the potentiometer’s principles except the fact that a photo resistor is light based whereas, the potentiometer is a twist based resistance.

In terms of coding, no new methods were introduced. What the program did is simply change the intensity of an LED based on the amount of light incident on the photo resistor. For this circuit, the pin the led got connected to is pin 9 because here, we are controlling brightness so we use one of the PWM (Pulse Width Modulation Pins).  The methods analogRead() and analogWrite() were also used in this lab to read/write the light level.

With the help of the CIRC-09 Breadboard Sheet, we put together this simple circuit. The Arduino Uno senses voltage and it can’t directly sense resistance so we had to set up a voltage divider. The voltage at the sensing pin is always assessable, but our purpose is sensing relative light so we experimented with the values to see what works for us.

TIME TO COMPLETE:

It took us exactly 8 minutes to build the circuit and about 6 minutes to code.

RESULTS:

The circuit was set up well and the program was coded, downloaded the right way. Hence, our circuit worked effectively in our first try. A low value occurred when the sensor was well lit and a high value occurred when it was in darkness.

PHOTOS OF PROJECT:


Due to the lack of Varshini's photography skills,
the LED in the above pictures is not lighting up.
TIPS:

Don’t forget that a photo resistor needs to be in a voltage divider before it provides a useful input.

After you program your circuit, if the LED remains dark then pull it up and give it a twist.

If you're in a room that is either too bright or dark, your circuit might not work. Try turning the light on or off to see if it works or, take a flashlight and give that a try.

FURTHER WORK:

To make my program better, I would like to reverse the response of the circuit. This can be easily done by changing the analogWrite(ledPin, lightLevel); -----> analogWrite(ledPin, 225 - lightLevel); . In addition, rather than controlling the brightness of the LED in response to light, I would like to turn it on and off based on a threshold value. This can be obtained by changing the loop() code with:

void loop()
 {
    int threshold = 300;
    if(analogRead(lightPin) > threshold){
       digitalWrite(ledPin, HIGH);
    }else{
       digitalWrite(ledPin, LOW);
    }
}
  
PROGRAM MODIFICATIONS:

My program is exactly the same as the one from:

PROGRAM (with comments):

/*
 * A simple programme that will change the intensity of
 * an LED based  * on the amount of light incident on
 * the photo resistor.
 *
 */

//PhotoResistor Pin
int lightPin = 0; //the analog pin the photoresistor is
                  //connected to
                  //the photoresistor is not calibrated to any units so
                  //this is simply a raw sensor value (relative light)
//LED Pin
int ledPin = 9;   //the pin the LED is connected to
                  //we are controlling brightness so
                  //we use one of the PWM (pulse width
                  // modulation pins)
void setup()
{
  pinMode(ledPin, OUTPUT); //sets the led pin to output
}
 /*
 * loop() - this function will start after setup
 * finishes and then repeat
 */
void loop()
{
 int lightLevel = analogRead(lightPin); //Read the
                                        // lightlevel
 lightLevel = map(lightLevel, 0, 900, 0, 255);
         //adjust the value 0 to 900 to
         //span 0 to 255



 lightLevel = constrain(lightLevel, 0, 255);//make sure the
                                           //value is betwween
                                           //0 and 255
 analogWrite(ledPin, lightLevel);  //write the value
}

REFERENCE:
·         http://ardx.org/VODI
·         http://ardx.org/VIDE09


No comments:

Post a Comment