element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Project14
  • Challenges & Projects
  • More
Project14
Show and Tell! Turning my old Lamp into Smart Lamp
  • News
  • Member Updates
  • Competitions
  • Forum
  • Documents
  • Theme Suggestions
  • Polls
  • Members
  • More
  • Cancel
  • New
Join Project14 to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: reeva
  • Date Created: 30 Aug 2026 5:35 PM Date Created
  • Views 58 views
  • Likes 4 likes
  • Comments 0 comments
Related
Recommended

Turning my old Lamp into Smart Lamp

reeva
reeva
30 Aug 2026

This project outlines the process of upgrading a standard lamp enclosure into an automated, touch-controlled smart lamp using a microcontroller and basic sensors.

Smart Features

  • Intelligent Automation: The LDR continuously monitors ambient room light, ensuring the lamp only activates when the environment is actually dark.

  • Touch Dimming: A long press on the TTP223 sensor adjusts the brightness via PWM, allowing you to set a mood or conserve battery life.

  • Soft-Off (Grace Period): To prevent accidental blackouts from sensitive touch sensors, tapping to turn the lamp off triggers a 5-second blinking countdown before cutting power. Touching the sensor again during this period cancels the shutdown.

Wiring the Power Supply

The TP4056 module safely charges the battery and provides power to the Arduino. Because the ATmega328 chip on the Nano operates between 1.8V and 5V, the 3.5V-4.2V output of the Li-ion battery can connect directly to it.

  • Battery (+) → TP4056 B+

  • Battery (-) → TP4056 B-

Connecting the Sensors

LDR (Light Sensor):

  • LDR Leg 1 → Arduino 5V

  • LDR Leg 2 → Arduino A1

  • Resistor Leg 1 → Arduino A1 (Shares the pin with LDR Leg 2)

  • Resistor Leg 2 → Arduino GND

image

TTP223 Touch Sensor:

  • VCC → Arduino 5V

  • GND → Arduino GND

  • I/O Pin → Arduino D6

Connecting the LED & MOSFET

Arduino pins cannot supply enough current to directly power a high-brightness LED, so the IRFZ44N MOSFET acts as an electronic switch.

  • Gate (Pin 1) → Arduino D11

  • Drain (Pin 2) → LED Negative

  • Source (Pin 3) → Arduino GND

  • LED Positive → TP4056 OUT+

image

image

Code Logic

Stable Readings: The Arduino reads the LDR sensor 50 times rapidly (with a 1ms delay) and calculates the average to get a stable, reliable value. A higher value (> 800) means Dark, and a lower value means Bright. The lamp turns on or off according to these values.

Anti-Flicker Mechanism: This is the most important part of the code! When the lamp turns on in a dark room, the room suddenly becomes bright. If the Arduino checked the light level normally, it would think, "It's bright now!" and turn the lamp off, causing endless flickering.

The Fix: Immediately after turning the LED on, the code waits 500ms for the system to stabilize. It then takes a new brightness reading which also includes the lamp's own light and saves it as a current_reference variable. This value effectively becomes the new baseline. The Arduino is now saying, "Okay, this brightness level is the new 'Dark'. I will ignore this much light."

Testing the Prototype

Before adding the circuit inside lamp i need to test it so that if any problem occurs i can fix it easily

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

The Final Assembly
You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube