Tuesday, 1 November 2011

CIRC-09: Photo-Resistors

Purpose: 
Adjust the brightness of an LED with the photo-resistor by the amount of light that comes in contact.

Equipment:
•1 x Arduino Uno
•1 x Breadboard
•6 x Wire
•1 x Photo-Resistor
•1 x 560 Ohm Resistor
•1 x 10k Ohm Resistor
•1 x LED

Reference:
http://www.oomlout.com/a/products/ardx/circ-09

Program Details: 
The code for this lab is identical to CIRC-08. No new concepts are present.

Time to Complete: 
 15 minutes

Results:
The LED was brighter with the exposure to light. The lab worked without a problem.

Photos of Project: 




Tips:
The two different resistors belong in two different places. Make sure you don't mix them up.

Further Work:
Create different actions for different thresholds. For example, blinking when exposed to no light, off when exposed to light.

Program Modifications:
The program is exactly the one from http://www.oomlout.com/a/products/ardx/circ-09

Program:
int sensorPin = 0;    // the pin the sensor is connected to
int ledPin = 13;      // the pin the LED is connected to
int sensorValue = 0;  // a variable to hold the state of the sensor
void setup()
{
  pinMode(ledPin, OUTPUT);  //initialize pin 13 as an output
}
void loop()
 {
  //reads the value from the sensor and sets it to sensorValue
  sensorValue = analogRead(sensorPin);    
  digitalWrite(ledPin, HIGH);  //sets the state of ledPin to high(on)
  delay(sensorValue);          //delay equal to the value of sensorValue
  digitalWrite(ledPin, LOW);  //sets the state of ledPin to low(off)
  delay(sensorValue);         //delay equal to the value of sensorValue

 }

No comments:

Post a Comment