Voice Assistant Lamp

by 1041987 in Circuits > Arduino

15 Views, 0 Favorites, 0 Comments

Voice Assistant Lamp

61NYkPbWjpL.jpg

Tired of turning your lamp on and off? Want a smart voice assistant that only listens when it’s needed?

This project combines an LDR (Light Sensor) with a voice assistant speaker, so that:

  1. The lamp turns on automatically in darkness.
  2. The lamp adjusts the brightness based on its surroundings
  3. The voice assistant only powers on when the lamp is on — saving power and privacy.

Perfect for a smart bedside lamp or study desk upgrade to get help when you need it.

Supplies

b.jpg
a.jpg

The following are the materials that I used to create this voice assistant lamp:

  1. 1602 I2C LCD Display Module Buy it here
  2. RGB Common Anode LED Buy it here
  3. Buzzer Buy it here
  4. 10 kΩ Resistor Pack Buy it here
  5. 330 Ω Resistor Pack Buy it here
  6. LDR Photoresistor Buy it here
  7. 1W LED Chip Bulb COB Light Beads Pure White Super Bright High Power for Floodlight Buy it here

Making the Lamp

d.jpg
c.jpg
b.jpg
a.jpg

I built the lamp using cardboard boxes and covered them with black and whhite paper to look better and assembled it with tape. You can use glue/adhesive to make it look even better!

Wiring

c.jpg
b.jpg
a.jpg

First we need to wire our breadboard to get the LDR and LED values so that we can train it in a AI model so that the LED will change its brightness based on our preference. In this circuit,we can control the led brightness with the potentiometer to what we like at that specific time of the day and press the button to record the led and ldr values at thst time.

Getting Data

Screenshot 2025-06-16 194838.png
Screenshot 2025-06-16 194855.png
Screenshot 2025-06-16 195448.png

This is the code to record the values of the LED and the LDR,make sure that the led is not facing the ldr as that will affect the values of the ldr. You can do this throughout the day at different times (50 -100) to get different recordings. The more values you get,the more accurate it will be for the AI to learn your preferred brightness level at different settings. After getting the values,put them in a txt file and after the txt file is made,convert it to a csv file. This will automatically put it in a excel file with all the values of the led and ldr and you can label it in the top row to make it easier for the AI to learn and understand

Training AI Model

Screenshot 2025-06-08 004424.png

In python,we will be creating a AI model and train it to our preferences using a library called sklearn which cotains the code to train our linear regression model so all we need to do is give it our LDR and LED values that we recorded,to do this,we will use pandas which will read our csv file that we made with the values. To download any library's for python that are needed in this guide,you have to go to the terminal in python and enter "pip install [library name]"


What is a linear regression model? A linear regression model uses the formula y = wX + b in which y is the led brightness that it is predicting,x is the LDR values and w and b are the parameters that we will be getting from this ai model.


After the model is trained and it learns our preferences,it gives us the w and b values that we can put in our arduino code for the lamp

Downloads

Voice Assistant Coding(Python Side)

Screenshot 2025-06-16 200804.png
Screenshot 2025-06-16 200814.png
Screenshot 2025-06-16 200824.png
Screenshot 2025-06-16 200835.png
Screenshot 2025-06-16 200846.png
Screenshot 2025-06-16 200906.png
Screenshot 2025-06-16 200913.png

The code uploaded below and the screenshots above are the code of the voice assistant which only listens to you when the lamp is turned on. We communcate this to the arduino and find out if the lamp is turned on or not by communicating through serial and connecting the python code to the port. When the led brightness of the lamp is greater than a specific value to turn on,the signal 'on' is sent to python which turns the voice assistant on otherwise the voice assistant stays off. The voice assistant looks for keywords such as summarize,google,,youtube etc in the user's speech when the lamp is on and asks what they want to search and searches it for them. We use multiple libraries like text to speech,playing audio files,taking in speech etc to make it work. All the code is commentated so you can read through it to understand how it functions

Downloads

Wiring Arduino

c.jpg
b.jpg
a.jpg
d.jpg

Since we are done with getting our values for the LDR and LED and have trained the AI model to adjust the brightness based on our preferences,we no longer need the button and potentiometer. I have also added a LCD display to show the brightness percentage of the LED, a buzzer that beeps when the led turns on and off and a RGB led that goes from red to green when the led turns on

Coding (Arduino Side)

Screenshot 2025-06-16 202211.png
Screenshot 2025-06-16 202222.png
Screenshot 2025-06-16 202254.png
Screenshot 2025-06-16 202248.png
Screenshot 2025-06-16 202233.png

Here we use the same code that we did in python (finding w and b) for the brightness of our led and we will put the values that python gave us in our w and b values. With this,the brightness of the led will change automatically based on the preferences we recorded. I also coded the RGB led to stay red when the lamp is off and turn green when the lamp is on. The buzzer makes a beep sound when the lamp turns on/off and we can also see the code in the arduino that sends the on/off signal to python to activate the voice assistant and the lcd to show the brightness percentage. Just like the python code,this code has been uploaded below and is commented to understand every step

Downloads

Put it all together and not your voice assistant lamp is finished for you to enjoy!