Jump to main content

Build a Voice-Controlled Lamp

62 reviews


"Alexa, turn on the lights!" Sometimes it is easy to take the technology around us for granted. But have you ever wondered how a smart speaker like an Amazon Echo® knows what you are saying and how it can control lights and appliances in your home? It can seem like magic if you buy a device that just works when you open the box. In this project, you will learn how it works. You will build your own smart home device to control an appliance with voice commands using an Arduino®. Get started creating your own smart home!


Areas of Science
Time Required
Short (2-5 days)
Previous experience with an Arduino is recommended.
Material Availability
A kit is available from our partner Home Science Tools. See the Materials section for details.
Do not cut or solder high-voltage wires (like the power cord for a lamp).
Ben Finio, PhD, Science Buddies
DIY Arduino Voice Controlled Lamp


Build a device that lets you use voice commands to control one or more household appliances.


Traditionally, most lights and household appliances have been controlled by manual switches and buttons. Today, though, many newer devices connect to the Internet, and they can be controlled from your phone or computer. These Internet-connected devices, sometimes called smart home devices, are part of the Internet of things (IoT), a network of devices other than traditional computers that are connected to the Internet and exchange data with each other.

Smart speakers like the Amazon Echo® (Figure 1) allow you to use voice commands to communicate with a virtual assistant like Apple's Siri®, Amazon's Alexa®, Microsoft's Cortana®, or Google®. You can use them to search the web, to play music, and even to control lights and appliances. These smart speakers use speech recognition to recognize the words that you say and convert them into commands that a computer can follow. This process is also called speech to text (STT), which is the opposite of text to speech (TTS), the process used by screen readers and virtual assistants to read text on a computer screen out loud.

An Amazon Echo dot, a small cylindrical smart speaker with four buttons on top
Figure 1. An Amazon Echo, a type of smart speaker.

You might also hear speech recognition referred to as voice recognition. The terms are sometimes used interchangeably, although technically speech recognition refers to the process of recognizing spoken words regardless of who is speaking them, and voice recognition refers to recognizing the voice of a specific person. Speech recognition is useful for speaker-independent commands, like controlling the lights in a household with multiple people. Voice recognition is useful for speaker-dependent actions, like using your voice to unlock a phone or computer.

Many smart speakers require a wake word, like "Alexa" or "Computer." This "wakes up" the speaker and tells it to listen for an additional command. It then sends a recording of what you say next over the Internet to a company like Apple or Google, where the information is processed and converted to text. This text is then converted to a command or an action for the program to take, like searching the web for something, playing a song, or turning on an appliance. Since these large companies have huge networks of smart speakers, phones, and computers all over the world, they can collect large amounts of data and use machine learning to improve their speech recognition. For example, they can train their speech recognition programs to work for people with different accents.

You might not have all the computing resources of Google at your disposal, but you can still use a popular prototyping platform like an Arduino to build your own smart home device. There are many third-party voice control modules available for the Arduino. These modules allow local processing of a limited set of voice commands without requiring an Internet connection. This lets you build a device where your voice acts as the input and an electrical signal to control an appliance is the output. The Procedure section of this project will show you how to use an Arduino to control one or more appliances using voice commands. You will need to make some design choices and use the engineering design process to design your voice control system.

The Arduino operates at 5 volts (V) direct current (DC), which is useful for powering small lights and motors. However, appliances that plug into a wall outlet typically operate at 120 V alternating current (AC) in the U.S. (This voltage may vary depending on your country). It is not safe to handle the exposed metal of 120 V AC wires directly (this is why we teach small children not to stick their fingers into electrical outlets!). The Procedure section of this project will explain how you can control a device that plugs into a wall outlet using an Arduino without modifying any of the high-voltage wires.

Terms and Concepts



Materials and Equipment Buy Kit

Recommended Project Supplies

Get the right supplies — selected and tested to work with this project.

View Kit

This is an engineering design project. The following is a list of materials to get you started, but you may need additional parts depending on which speech recognition platform you decide to use and what you want to control with your Arduino.

Disclaimer: Science Buddies participates in affiliate programs with Home Science Tools, Amazon.com, Carolina Biological, and Jameco Electronics. Proceeds from the affiliate programs help support Science Buddies, a 501(c)(3) public charity, and keep our resources free for everyone. Our top priority is student learning. If you have any comments (positive or negative) related to purchases you've made for science projects from recommendations on our site, please let us know. Write to us at scibuddy@sciencebuddies.org.

Experimental Procedure

Note: This engineering project is best described by the engineering design process, as opposed to the scientific method. You might want to ask your teacher whether it's acceptable to follow the engineering design process for your project before you begin. You can learn more about the engineering design process in the Science Buddies Engineering Design Process Guide.

Planning Your Voice Control System

Before you buy parts for your project, you will need to decide what appliance(s) you want to control, and how you want to control it. For example:

  • Will you control more than one appliance? What commands do you want to use? For example, if you are controlling a single lamp, the words "on" and "off" are probably sufficient. If you want to control multiple appliances independently, you may need different commands, such as "turn on the light" and "turn on the fan."
  • Do you want your voice control system to respond to everyone (speaker-independent) or only to you (speaker-dependent)?
  • Where will your appliance, Arduino, and microphone be located? For example, do you want to be able to walk into a room and use your voice to turn on a floor lamp that is across the room? Will you control a desk lamp while sitting at the desk?
  • What is your budget? Some of the modules are more expensive than others.
  • Is there potential for background noise?

You can always modify your plan later, but make sure you know what you want to do before you start buying parts.

Choosing a Speech Recognition Module

Based on your plan for your voice control system, you will need to choose a speech recognition module for your Arduino. There are many third-party modules available with different features. You can read about the features of each module on its website. (See the Materials section for examples). Before buying one, consider the following:

  • Some modules come unassembled and require soldering to attach header pins. If you do not have access to a soldering iron, make sure you purchase a module that does not require soldering.
  • Some modules come with built-in commands that you do not need to train.
  • Some modules allow you to train new commands and some do not.
  • Some modules are speaker-dependent and some allow speaker-independent commands.
  • Different modules can store different numbers of commands of varying length. For example, some may allow you to record full sentences, while others may only allow commands that are a second or two long.
  • Some modules have an on-board microphone, while other modules have a connector for an external microphone.

Determine what features you need for your voice control system based on your plan. For example, if you want the system to work for everyone in your family, a speaker-independent module may be better. (If you use a speaker-dependent module, you will need to train each command separately for each person.) Some of the microphones that are built into or come with the speech recognition modules have a fairly short range. They may only work well when you are very close to them. That could be fine if you will use the device while sitting at a desk. If you prefer to be able to control an appliance from across the room or from different directions, a module that lets you connect a higher-quality or omnidirectional external microphone may be better.

There is no single "right answer" for which speech recognition module to buy. They all have different features and different prices. Which one is "best" for your project will depend on your criteria and constraints. Choosing one is part of the engineering design process.

The following two sections contain instructions for using the Elechouse Voice Recognition Module V3, which allows you to train multiple speaker-dependent commands, and the Grove Speech Recognizer, which comes pre-loaded with 22 speaker-independent commands but does not let you train new commands. If you choose another speech recognition module, you will need to follow the instructions for the module you purchase.

Using the Elechouse Voice Recognition Module V3

Watch this video for an overview of how to set up and use the Elechouse Module V3, or follow the written steps below.

Elechouse Voice Recognition Module V3.1 and Arduino - Setup and Tutorial
  1. Solder header pins to the GND, VCC, RXD, and TXD pins.
  2. Plug the microphone into the microphone jack.
  3. Plug the header pins into a breadboard. Alternatively, you can use male-female (M-F) jumper wires to connect the module directly to the Arduino without using a breadboard.
  4. Use jumper wires to make the following connections to the Arduino (Figure 2).
    1. Elechouse GND to Arduino GND
    2. Elechouse VCC to Arduino 5V
    3. Elechouse RXD to Arduino digital pin 3
    4. Elechouse TXD to Arduino digital pin 2
    Elechouse Voice Recognition V3 module inserted into a breadboard and connected to an Arduino UNO with jumper wires
    Figure 2. Elechouse Voice Recognition Module V3 connected to an Arduino UNO.
  5. Download the Arduino library from the Elechouse website.
  6. Extract the .zip folder to the Arduino libraries folder on your computer. This folder may be saved in a location such as C:\Program Files (x86)\Arduino\libraries.
  7. Connect your Arduino to your computer and open the Arduino Integrated Development Environment (IDE).
  8. Select File > Examples > VoiceRecognitionV3 > vr_sample_train.
  9. Under Tools, make sure you have the correct Arduino board and COM port selected.
  10. Upload the program to your Arduino.
  11. Select Tools > Serial monitor.
  12. Set the baud rate to 115200.
  13. Type "train 0" in the box at the top of the serial monitor and press Enter.
  14. Watch the serial monitor. When it prints "speak now," say "On" clearly.
  15. When it prints "speak again," say "On" again.
  16. If the two recordings do not match, the program will continue prompting you to speak. Keep repeating the phrase until it prints "success."
  17. Enter "train 1" then repeat steps 14–16 for the word "Off."
  18. Enter the command "load 0 1". This loads the two commands you just recorded into memory for use with voice control.
  19. Try saying "On" or "Off." The serial monitor should print out "VR Index," followed by the index number of the matching command (0 for "On" and 1 for "Off"). If it does not print anything, make sure you are speaking clearly and at the same distance from the microphone as when you recorded the command.
  20. Select File > Examples > VoiceRecognitionV3 > vr_sample_control_led. Upload the program to your Arduino.
  21. Try speaking the words "On" and "Off" to control the Arduino's onboard LED (the small LED labeled "L" near Arduino pin 13).
  22. You can now use your voice recognition module to control a single appliance by connecting pin 13 to the IoT relay.
  23. To control multiple appliances, you will need to train additional command words following the procedure above and modify the vr_sample_control_led program to control additional Arduino pins.

Using the Grove Speech Recognizer

Watch this video for an overview of how to set up and use the Grove Speech Recognizer, or follow the written steps below.

Grove Speech Recognizer for Arduino - Setup and Tutorial
  1. Plug the included cable into the 4-pin header on the Grove Speech Recognizer board.
  2. Use jumper wires to connect the wires in the cable to your Arduino (Figure 3):
    1. Black wire to Arduino GND
    2. Red wire to Arduino 5V
    3. Yellow wire to Arduino pin 2
    4. White wire to Arduino pin 3
    Grove speech recognizer board connected to the Arduino with a ribbon cable and jumper wires
    Figure 3. Grove Speech Recognizer board connected to the Arduino.
  3. Go to the Seeed Studio wiki page, scroll down, copy the example code, and paste it into your Arduino IDE.
  4. Under Tools, make sure you have the correct Arduino board and COM port selected.
  5. Upload the program to your Arduino.
  6. Select Tools > Serial monitor.
  7. Set the baud rate to 9600.
  8. Say the wake word "hicell" (the words "hi" and "cell" pronounced together as one word). The red LED on the board should light up when it recognizes the wake word, indicating that the board is waiting for a command.
  9. Once the red LED is lit up, speak one of the command words or phrases. There are 22 commands listed in the example program — for example, "Start" and "Stop." If the board recognizes the command, the blue LED should light up and it will print the command to the serial monitor.
  10. Download grove_control_LED.ino and upload it to your Arduino. This is a slightly modified version of the example code that uses the commands "Turn on the light" and "Turn off the light" to control the Arduino's onboard LED.
  11. Try saying the wake word followed by "Turn on the light." The Arduino's onboard LED (the one labeled "L" near pin 13) should turn on. Then say the wake word followed by "Turn off the light" and the LED should turn off. Remember that you need to say the wake word again for each new command. If it does not work, make sure you are close to the microphone and speaking clearly, then try again.
  12. You can now use the speech recognizer to control a single appliance by connecting pin 13 to the IoT relay.
  13. To control multiple appliances, you will need to further modify the code as shown in grove_control_LED.ino to make use of additional commands and other Arduino pins.

Using the IoT Relay

Caution:The IoT relay allows you to safely control a high-voltage appliance that plugs into a wall outlet using a low-voltage control signal from a microcontroller like the Arduino. Remember that you should never cut or modify the high-voltage wires (like the power cord for an appliance) directly.

Watch this video or follow the written instructions below to learn how to set up and use the IoT relay:

IoT Power Relay and Arduino - Setup and Tutorial
  1. Pull the green screw terminal connector out from the side of the IoT relay.
  2. Loosen the screws, insert one end of a jumper wire into each terminal, then re-tighten the screws.
  3. Connect the "+" wire to Arduino pin 13 and the "-" wire to GND. (See Figure 4.)
  4. Make sure the power switch on the IoT relay is in the Off position.
  5. Plug an appliance, like a lamp, into one of the "normally off" outlets on the IoT relay.
  6. Upload the Blink example code to your Arduino (File > Examples > 01.Basics > Blink).
  7. Turn on the power switch on the IoT relay. Your appliance should turn on and off repeatedly.
  8. Turn off the power switch on the IoT relay.
The IoT relay connected to an Arduino UNO with two jumper wires. An off-screen appliance is plugged in to the IoT relay.
Figure 4. IoT relay connected to the Arduino with jumper wires.

Build Your Smart Home Device

Using the information in the sections above, you should now be ready to set up your own voice-controlled smart home appliance.

  1. Set up your voice recognition module. You can follow the instructions in one of the sections above, or follow the instructions that came with your module if you purchased a different one.
  2. Test your voice commands and use them to control the Arduino's onboard LED so you can confirm that they are working.
  3. Connect your Arduino to the IoT relay and plug in an external appliance so you can switch it on and off.
  4. Depending on what you want your project to do, test it in different scenarios. For example, do the voice commands work for everyone in your household? Do they work from across the room or if there is background noise?
  5. Look at your test results and decide if your solution meets all your design requirements. If not, what can you do to improve it? Do you need to re-train any of the commands or move the microphone to improve performance? Do you need to revisit the requirements to get the results you envisioned?
  6. Keep track of all your test results and make notes on any changes so you can communicate your work to others.
icon scientific method

Ask an Expert

Do you have specific questions about your science project? Our team of volunteer scientists can help. Our Experts won't do the work for you, but they will make suggestions, offer guidance, and help you troubleshoot.

Global Connections

The United Nations Sustainable Development Goals (UNSDGs) are a blueprint to achieve a better and more sustainable future for all.
This project explores topics key to Industry, Innovation and Infrastructure: Build resilient infrastructure, promote sustainable industrialization and foster innovation.


  • Can you use your Arduino to control motors and use voice commands to make something move?
  • If you search online, you will find many Arduino projects that use a Bluetooth module to connect an Arduino to a phone. Can you use your phone to control an appliance instead of (or in addition to) your voice?
  • Can you build a voice-activated robot?
  • How reliable is your voice recognition module? Do a project using the scientific method instead of the engineering design process. For example, pick a single command and repeat it 10 times at different distances from the microphone.


If you like this project, you might enjoy exploring these related careers:

Career Profile
Just as a potter forms clay, or a steel worker molds molten steel, electrical and electronics engineers gather and shape electricity and use it to make products that transmit power or transmit information. Electrical and electronics engineers may specialize in one of the millions of products that make or use electricity, like cell phones, electric motors, microwaves, medical instruments, airline navigation system, or handheld games. Read more
Career Profile
Whether you are playing video games, surfing the Internet, or writing a term paper, computers are an integral part of our daily lives. Computer hardware engineers work to make computers faster, more robust, and more cost-effective. They design the microprocessor chips that make your computer function, along with the equipment that makes computing easy and fun to do. Read more
Career Profile
Are you interested in developing cool video game software for computers? Would you like to learn how to make software run faster and more reliably on different kinds of computers and operating systems? Do you like to apply your computer science skills to solve problems? If so, then you might be interested in the career of a computer software engineer. Read more

Contact Us

If you have purchased a kit for this project from Science Buddies, we are pleased to answer your questions.

In your email, please follow these instructions:
  1. What is your Science Buddies kit order number?
  2. Please describe how you need help as thoroughly as possible:


    Good Question I'm trying to do Experimental Procedure step #5, "Scrape the insulation from the wire. . ." How do I know when I've scraped enough?
    Good Question I'm at Experimental Procedure step #7, "Move the magnet back and forth . . ." and the LED is not lighting up.
    Bad Question I don't understand the instructions. Help!
    Good Question I am purchasing my materials. Can I substitute a 1N34 diode for the 1N25 diode called for in the material list?
    Bad Question Can I use a different part?

Contact Us

News Feed on This Topic

, ,

Cite This Page

General citation information is provided here. Be sure to check the formatting, including capitalization, for the method you are using and update your citation, as needed.

MLA Style

Finio, Ben. "Build a Voice-Controlled Lamp." Science Buddies, 26 Oct. 2023, https://www.sciencebuddies.org/science-fair-projects/project-ideas/Elec_p093/electricity-electronics/arduino-voice-controlled-lamp. Accessed 30 Nov. 2023.

APA Style

Finio, B. (2023, October 26). Build a Voice-Controlled Lamp. Retrieved from https://www.sciencebuddies.org/science-fair-projects/project-ideas/Elec_p093/electricity-electronics/arduino-voice-controlled-lamp

Last edit date: 2023-10-26
Free science fair projects.