This is an old revision of the document!


Smart Lamp

Introduction

The Smart Lamp is an embedded system project that implements an adaptive RGB LED strip lighting solution with two distinct operating modes, built around the ATmega328P Xplained Mini board. In Manual Mode, the user controls the LED brightness directly via a potentiometer. The analog signal is read through ADC and converted to three identical PWM duty cycles that drive the R, G, and B channels. In Automatic Mode, a photoresistor senses the ambient light level, and the microcontroller automatically adjusts the LED brightness — brighter in dark environments, dimmer when the surroundings are well-lit. At any moment, the current brightness level (0–100%) is displayed on a 16×2 LCD connected via I2C. The user switches between modes by pressing the onboard button.

The motivation behind this project comes from two sources: the growing interest in smart home automation and energy-efficient lighting and the need for a compact and easy to use lamp for my desk. This auto-dimming lamp is a practical system that demonstrates core concepts for embedded projects.

General Description

Block scheme description:

  • ATmega328P Xplained Mini — reads ADC inputs, generates PWM output for LED brightness control, drives the LCD over I2C, and handles button press interrupts to toggle modes.
  • RGB LED Strip — the output actuator. The strip has a common anode (+5V) and three separate cathode lines (R, G, B). All three channels receive the same PWM duty cycle, producing white light at variable brightness.
  • External Power Supply (5V) — powers the RGB LED strip. GND of the external supply is connected to the MC GND.
  • Potentiometer — used in Manual Mode as a variable voltage divider. The wiper voltage is read on ADC0 (PC0) and mapped to a PWM duty cycle.
  • Photoresistor + Pull-down Resistor — used in Automatic Mode. The LDR and resistor form a voltage divider; the midpoint is read on ADC1 (PC1). Lower ambient light → lower voltage → higher duty cycle → brighter LED.
  • 16×2 LCD with I2C adaptor — displays the current brightness percentage and the active mode. Communicates with the MCU via I2C.
  • User Button (onboard) — toggles between Manual and Automatic modes. Connected to pin PB7 on the Xplained Mini board.

Hardware Design

Bill of Materials

# Component Value / Model Qty Notes
1 ATmega328P Xplained Mini Microchip 1 MCU development board
2 RGB LED Strip 5V, 15 LEDs, common anode 1 Output lamp
3 NPN Transistor 2N2222 3 Low-side switch for each RGB channel
4 Resistor 1 kΩ 3 Base current limiter for 2N2222
5 Resistor 220 Ω 1 LED current limiter
6 Resistor 10 kΩ 1 LDR voltage divider pull-down
7 Potentiometer 10 kΩ, linear 1 Manual brightness control
8 Photoresistor (LDR) GL5528 or similar 1 Auto mode light sensor
9 LCD Display 16×2, I2C (PCF8574) 1 Brightness level display
10 Breadboard 400 point 1 Component mounting
11 Jumper wires M-M, F-F ~20 Connections
12 USB cable Micro-USB 1 Power & programming

Electrical Schematic

* Note: in the above electrical schematic the LDR is a complete module including the R2 voltage divider

Pin Mapping

ATmega328P Pin Arduino Pin Signal Connected To
PD6 (OC0A) D6 PWM LED LED anode (via R1, 220 Ω)
PC0 (ADC0) A0 ADC input Potentiometer wiper
PC1 (ADC1) A1 ADC input LDR voltage divider midpoint
PC4 (SDA) A4 I2C SDA LCD SDA
PC5 (SCL) A5 I2C SCL LCD SCL
PB7 D7 GPIO input Onboard button
VCC 5V 5V VCC potentiometer, VCC LCD, VCC LDR
GND GND GND LED catod,GND potentiometer, GND LCD, GND LDR

Software Design

TODO

Results Obtained

TODO

Conclusions

TODO

Journal

TODO

Resources

TODO

pm/prj2026/vlad.radulescu2901/sebastian.coitu.1778686945.txt.gz · Last modified: 2026/05/13 18:42 by sebastian.coitu
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0