Introduction: Experiment 7: Light Control of LED Switch

Photoresistor is a special resistor, it referred to light resistance also , and its resistance related to the intensity of light directly; light intensity increases, the resistance reduction; light intensity decreases, the resistance increases.

Here, we take a look at using the photoresistor to make a LED light control switch.

 

 

Step 1: Parts List

1. PcDuino experimental platform

2. photoresistor

3.LED

4.resistor:220 ohm

5.resistor:10K ohm

6.the jumper

Step 2: Wire Diagram

Step 3: Sample Code

 
int photoresistancePin = 0;
int ledPin = 11;
int val = 0;
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
val = analogRead(photoresistancePin);
if(val<=40){
digitalWrite(ledPin, LOW);
}
else{
digitalWrite(ledPin, HIGH);
}
}

Step 4: Results

Bright light environments

Step 5: Results

Dark environments

Comments

About This Instructable

1,206views

12favorites

License:

More by pcduino:Use Button to Control LED on pcDuino with JavaUse Arduino and RS232 Shield to interface Integrated UHF RFID reader LSID-0702Experiment 4 Serial Port Communication
Add instructable to: