Using Photoresistors with an Arduino
DISCLAIMER & USAGE The content of this presentation is for informational purposes only and is intended for students attending Louisiana Tech University only. The authors of this information do not make any claims as to the validity or accuracy of the information or methods presented. Any procedures demonstrated here are potentially dangerous and could result in damage and injury. Louisiana Tech University, its officers, employees, agents and volunteers, are not liable or responsible for any injuries, illness, damage or losses which may result from your using the materials or ideas, or from your performing the experiments or procedures depicted in this presentation. The Living with the Lab logos should remain attached to each slide, and the work should be attributed to Louisiana Tech University. If you do not agree, then please do not view this content. boosting application-focused learning through student ownership of learning platforms
Implement photoresistor circuit 5V analog input 2 photoresistor 10kW
Enter and run the following sketch int val = 0; // variable to store value read at analog pin 2 void setup() { Serial.begin(9600); // set up to print out text to monitor } void loop() { val = analogRead(2); // read analog input pin 2 Serial.println(val); // print value to serial monitor What happens to the values on your serial monitor when you put your hand over the photoresistor?
Implement photoresistor and LED circuits 220Ω digital pin 11 5V analog input 2 photoresistor 10kW
Enter and run the following sketch int val = 0; // variable to store value read at analog pin 2 void setup() { Serial.begin(9600); // set up to print out text to monitor pinMode(11,OUTPUT); // declare pin 11 as an output } void loop() { val = analogRead(2); // read analog input pin 2 Serial.println(val); // print value to serial monitor if(val < 600) // if statement used to control LED { digitalWrite(11,HIGH); delay(100); digitalWrite(11,LOW); delay(100); How does the photoresistor control the LED?