Using Photoresistors with an Arduino 1 DISCLAIMER USAGE

  • Slides: 6
Download presentation
Using Photoresistors with an Arduino 1

Using Photoresistors with an Arduino 1

DISCLAIMER & USAGE • The content of this presentation is for informational purposes only

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. boosting application-focused learning through student ownership of learning platforms • 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. 2

Implement photoresistor circuit 5 V photoresistor analog input 2 10 k. W 3

Implement photoresistor circuit 5 V photoresistor analog input 2 10 k. W 3

Enter and run the following sketch int val = 0; // variable to store

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 = analog. Read(2); Serial. println(val); } // read analog input pin 2 // print value to serial monitor What happens to the values on your serial monitor when you put your hand over the photoresistor? 4

Implement photoresistor and LED circuits 220Ω digital pin 11 5 V photoresistor analog input

Implement photoresistor and LED circuits 220Ω digital pin 11 5 V photoresistor analog input 2 10 k. W 5

Enter and run the following sketch int val = 0; // variable to store

Enter and run the following sketch int val = 0; // variable to store value read at analog pin 2 void setup() { Serial. begin(9600); pin. Mode(11, OUTPUT); } // set up to print out text to monitor // declare pin 11 as an output void loop() { val = analog. Read(2); Serial. println(val); // read analog input pin 2 // print value to serial monitor if(val < 600) // if statement used to control LED { digital. Write(11, HIGH); delay(100); digital. Write(11, LOW); delay(100); } } How does the photoresistor control the LED? 6