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


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);
digitalWrite(ledPin, LOW);
digitalWrite(ledPin, HIGH);

Step 4: Results

Bright light environments

Step 5: Results

Dark environments



    • Toys Contest

      Toys Contest
    • First Time Author

      First Time Author
    • Big and Small Contest

      Big and Small Contest