3.0 Simple Photocell Project
This project will demonstrate using the Arduino to sense light and dark using a photocell.
Connect your components as follows:
The resisters in series create a Voltage Divider. Our project is going to use Analog pin A0 to read the voltage.
Create an Arduino sketch with the following Code:
/*NAME
Photocell Project
Engineering Period 1
DATE
Revision History
DATE | NAME | Changes Made
------|------------|------------------------------
TODAY | My Name | Initial Implementation
*/
// the setup routine runs once when you press reset or apply power:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
//Set pin A0 For Input - Allow us to read the value
pinMode(A0, INPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
//Send the output to the Serial Port
Serial.println(sensorValue);
}
After you have written your code, compile and upload the code to the Arduino. Once the code has been uploaded to the Arduino, from the tools menu select serial monitor.
- What values are you seeing?
- What happens when you cover the photocell?