Arduino Nightlight

Published

Introduction: 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.

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);

}

Share

    Recommendations

    • Creative Misuse Contest

      Creative Misuse Contest
    • Water Contest

      Water Contest
    • Clocks Contest

      Clocks Contest

    Discussions