Light Sensor (Photoresistor) With Arduino in Tinkercad

Overview

This project tells about how to use a photoresistor sensor to glow an LED this is very useful to detect light.

In this project when there is light present Led will be Off and in night Led will automatically turns On.

Hardware required 

  1. Arduino Uno R3
  2. LED
  3. Resistor
  4. Jumper Wires
  5. Photoresistor Sensor

Schematic Diagram

Fig 1.  Circuit Diagram

Arduino Code : 

int light = 0; // store the current light value

void setup() {
    // put your setup code here, to run once:
    Serial.begin(9600); //configure serial to talk to computer
    pinMode(7, OUTPUT); // configure digital pin 7 as an output
}

void loop() {
    // put your main code here, to run repeatedly:
    light = analogRead(A0); // read and save value from PR
    
    Serial.println(light); // print current light value
 
    if(light > 450) { // If it is bright...
        Serial.println("It is quite light!");
        digitalWrite(7,LOW); //turn  LED off
    }
    else if(light > 229 && light < 451) { // If it is average light...
        Serial.println("It is average light!");
       digitalWrite(7, HIGH); // turn LED on
    }
    else { // If it's dark...
        Serial.println("It is pretty dark!");
        digitalWrite(7,HIGH); // Turn  LED on
    }
    delay(1000); // don't spam the computer!
}

Precautions

  1. Connections should be done properly.
  2. Arduino is case Sensitive so code accordingly.
  3. Give different and appropriate colors to the wires.
  4. Use resistors for sensors and LED’s.

Do you have questions regarding our STEM program?

Contact us anytime.

Take your first step into the magical world of coding for kids

Share:

More Posts

Send Us A Message

Coding For kids

Our courses which are tailored for grades 1 to 12, and our hands-on curriculum seamlessly integrates, preparing students for challenges and inspiring the next generation.

STEM Labs

If you are a school searching for a cutting-edge makerspace solution that goes beyond conventional education, look no further. Partner with Makers’ Muse to unlock a world of innovation and transformative learning experiences for your students. 

Coding Toys

Discover a revolutionary coding journey for students with our cutting-edge educational toys. Partner with us to unlock innovative learning experiences that transcend traditional education.

Leave a Reply