Arduino Nightlight

About: Makeistan is a makerspace at Information Technology University in Lahore, Pakistan.

Today you will be learning how to make a simple nightlight using Arduino, and this is a project for beginners. So, lets get started! The principle this will use is the LDR will measure the intensity of the light, so we have programmed the Arduino to turn on LED's if the intensity is less than a certain threshold, and if it is greater than a threshold the LED's will remain off.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: What You Will Need

You will need:

- an Arduino

- a Breadboard

- 5 Male-Male Jumper Wires

- 1-4 LED's

- a Light Dependent Resistor(LDR)

- and a 1k Ohm Resistor

Step 2: Making the Circuit

Here is a diagram of the circuit.

Step 3: The Code

Here is the code:

int led = 13;
int ldr = A0;

int value;

void setup() {

pinMode(led, OUTPUT);

pinMode(ldr, INPUT);

}

void loop() {

value = analogRead(ldr);

if (value > 300){

digitalWrite(led, HIGH);

}

else{

digitalWrite(led, LOW);

}

delay(100);

}

Be the First to Share

    Recommendations

    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    Discussions