Level 1 · Design Scenario 1

Design an automatic night light.

This is not a copy-the-code exercise. We will take a simple customer brief and work through it like an engineering design task: requirements, inputs and outputs, system plan, circuit, breadboard build, pseudocode, Arduino code and a test plan.

The customer brief

Design a small automatic night light for a corridor. The lamp should stay off when the room is bright, turn on when it becomes dark, and become brighter as the light level falls. The user must be able to adjust the point at which the lamp starts operating.

Requirements

  • Sense room brightness.
  • Allow the user to adjust the switching threshold.
  • Use a dimmable LED output.
  • Show sensor and threshold values in Serial Monitor during testing.
  • Use only Level 1 techniques.
▶ YOUTUBE DESIGN WALKTHROUGHSuggested title: “Arduino Automatic Night Light — From Design Brief to Tested Circuit”

1. Identify the inputs and output

LDR voltage divider→Arduino A0→Decision→PWM LED on pin 9
Potentiometer→Arduino A1→Adjustable threshold

The LDR tells us how bright the room is. The potentiometer gives the user an adjustable number. The Arduino compares those two values and controls LED brightness.

2. System plan diagram

Light in room→LDR + 10 kΩ divider→A0 analogue value→Arduino logic→PWM 0–255→LED brightness
User turns knob→10 kΩ potentiometer→A1 threshold value

3. Circuit diagram

LDR voltage divider5VLDRA010 kΩGNDThreshold control5V — potentiometer — GNDcentre wiper → A1PWM outputPin 9 → 220–330 Ω → LED → GND

4. Breadboard build plan

LDR divider
5V → LDR → A0 junction → 10 kΩ → GND
Potentiometer
Outer pins to 5V and GND; centre pin to A1
LED
Pin 9 → resistor → LED anode; cathode → GND
Common rails
UNO 5V to + rail and UNO GND to – rail
Expected analogue direction: with the LDR above the fixed resistor as shown, darker conditions should produce a lower A0 reading. Check this in Serial Monitor before writing the control logic.

5. Pseudocode

START
Set LED pin as output
Start Serial Monitor

REPEAT FOREVER
Read light sensor from A0
Read user threshold from A1
Print both values

IF light value is lower than threshold
  Calculate a brightness value
  Send brightness to PWM LED
ELSE
  Turn LED off
END IF
Wait a short time
REPEAT

6. Arduino code

const int ldrPin = A0;
const int thresholdPin = A1;
const int ledPin = 9;

void setup() {
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  int lightLevel = analogRead(ldrPin);
  int threshold = analogRead(thresholdPin);
  int brightness = 0;

  if (lightLevel < threshold) {
    brightness = 255 - (lightLevel / 4);

    if (brightness > 255) {
      brightness = 255;
    }
  }
  else {
    brightness = 0;
  }

  analogWrite(ledPin, brightness);

  Serial.print("Light: " );
  Serial.print(lightLevel);
  Serial.print("  Threshold: " );
  Serial.print(threshold);
  Serial.print("  LED: " );
  Serial.println(brightness);

  delay(100);
}

This is intentionally direct Level 1 code. The learner can see each reading, decision and output without hiding the process inside arrays or more abstract program structures.

7. Test plan

TestInput / conditionExpected resultActual resultPass?
1Bright roomLED remains off
2Cover LDR graduallyLED turns on and becomes brighter
3Turn threshold control clockwiseSwitching point changes
4Turn threshold control fully the other waySwitching point changes in opposite direction
5Observe Serial MonitorA0, A1 and LED values change sensibly
6Disconnect LDRFault is visible in reading / behaviour and can be diagnosed

8. Evaluation questions

  • Did the system meet every requirement?
  • Was the threshold adjustment range useful?
  • Did the LED brightness change smoothly enough?
  • What happened at the exact switching point?
  • What would you improve if this were installed permanently?