Project tutorial
Simplest Way for Voice Recognition Project Using c#toarduino

Simplest Way for Voice Recognition Project Using c#toarduino © GPL3+

Easy way to control devices via voice commands.

  • 74 respects

Components and supplies

Ph a000066 iso (1) ztbmubhmho
Arduino UNO
Mfr 25fbf52 221r sml
Resistor 221 ohm
You can any resistance value of resistor just make sure dont use too less resistance value
09590 01
LED (generic)
I used led blue, Red, green led.
12002 04
Breadboard (generic)
11026 02
Jumper wires (generic)
Earphones with microphone
These earphones are the one you use with smarphones Simple! You can also use built_in Computer microphone :)

Apps and online services

Ide web
Arduino IDE
Microsoft Visual Studio 2015
You can use any version of Microsoft visual studio just make sure it contains .net framework to create windows form application

About this project

Note: Hi there,

I made this project 2 years back and got encouraging feedback. If you are a new member then I would recommend you to follow below (2020 updated tutorial )

Update tutorial link:

Thanks :)

Project Description

We all are blessed with different types of Sensors Such as (Ear, tongue, Nose...) and we use them in our daily life, not in one way but in two way communication there is the transmission and receiving of data going on.Same concept we are applying in machines!

As a beginner, almost everyone starts with blinking LEDs on/off and I also did that but I wanted to control these electronic components using my voice commands. So finally after I searched and learned from the internet I completed the project and ready to share this project with the creative community Especially (Beginners)!Simplest way for voice recognition using Arduino!

Just to make things simpler we are using LEDs. In this project, we will be turning on/off LEDs, not in a standard way but using our voice commands and exciting part is that it is very simple and easy just a little bit of programming knowledge is required that's all!

Why I made this Project?

It all started when my teacher demonstrated a c# windows form application project to us. In that project, Sir was Controlling virtual BULB using voice commands and it was made using c# visual studio software only no Arduino or any other hardware stuff. It was amazing :)So for a new project using Arduino, I thought why not control Led using voice command because in this project we are physically controlling hardware, not virtually which sir demonstrated.

Why this project is Simple?

There is one more important reason for this project and that's you makers I thought this project will help makers community to create something new out of it and voice recognition feature increases creativity, value of project!Now the amazing part why it is so simple? Because you don't need any external module to make this project :) I was sure that there must be a way I can make this project without using voice recognition module ! and finally found that way thanks to below link

How to Make it?

Gather all the components required for this project.

  • Design circuit on breadboard as below circuit diagram
  • Then plug in Arduino USB cable to your computer
  • download Arduino code open Arduino IDE and create a new sketch paste the code.

There is just one software you would need to install and that is the visual studio I am using Microsoft visual studio version 2010 and you can install any version you want just make sure you can create windows form application using c# from to download visual studio

Click below link and then click download->direct download

and you are done

  • upload your Arduino sketch and run the c# application by clicking the green arrow start button

Note#0: This Project will won't work if you have not included using.system.speech library in your visual studio c# code don't worry just follow below instruction to include libraryGo to above toolbar Project->Add Reference->.Net ->Search using.system.speech and click OK that's all :)

Note#1: Make Sure Your COM Port you selected in your Arduino IDE is the Same as in visual studio c# code.As You can see below mine COM Port is COM5 Same in Arduino and C# code.

If You are having any confusion just watch this demonstration video and you are ready to control LEDs using your voice :)

Click Here to Watch Youtube Project Demo

What did you make from this project?

Use your creativity to make something new out of this project.

Learn, Create, Share and Repeat


Arduino Source Code C/C++
Arduino Source Code for voice Recognition project
/* This Program is about controlling leds states ON and OFF using voice recognition library of c# (using system.speech) 
 * Exciting Part is you dont need to have any external module to transmit data to arduino because you can easily  
 * use your builtin computer microphone or earphones microphone.   
 * This Program is just to give basic idea specially to beginners and then its your own creativity how you use it in a useful way.
 * Keep Learning, Share, think and Repeat
 * Enjoy !
 * By Jalal Mansoori

const int blueLed=10;
const int redLed=9;
const int greenLed=8;

char incomingData='0';
void setup() {
  // put your setup code here, to run once:
//getting leds ready
pinMode(blueLed, OUTPUT);
pinMode(redLed, OUTPUT);
pinMode(greenLed, OUTPUT);

void loop() {
  // put your main code here, to run repeatedly:;

  // Switch case for controlling led in our case we have only 3 Blue, Green and Red 
      //These cases are only for state ON of led
      // For blue led
      case 'B':
      digitalWrite(blueLed, HIGH);
      // For red led
      case 'R':
      digitalWrite(redLed, HIGH);
      // For green led
      case 'G':
      digitalWrite(greenLed, HIGH);

      //These cases are  for state OFF of led and case name z , x, c are just randomly given you can also change but 
      // make sure you change it in a c# code as well.
      // For blue led
      case 'Z':
      digitalWrite(blueLed, LOW);
      // For red led
      case 'X':
       digitalWrite(redLed, LOW);
      // For green led
      case 'C':
       digitalWrite(greenLed, LOW);

      //For turning ON all leds at once :)
      case 'V':
      digitalWrite(blueLed, HIGH);
      digitalWrite(redLed, HIGH);
      digitalWrite(greenLed, HIGH);

      //For turning OFF all leds at once :)
      case 'M':
      digitalWrite(blueLed, LOW);
      digitalWrite(redLed, LOW);
      digitalWrite(greenLed, LOW);
C# CodeC#
This code is for visual studio. In this code you can see on top some libraries are included there is using.system.speech library which you need to include in your project reference
This is how you do it
Project->Add Reference->.Net-> Search using system.speech->click OK
Thats all Enjoy :)
  This Program is to connect c# and Arduino to transmit data from computer microphone to arduino board
  By Jalal Mansoori
using System;
using System.Windows.Forms;
using System.IO.Ports; // This library is for connecting c# and Arduino to transmit and receive data through ports
//Below are libraries for voice recognition
using System.Speech;
using System.Speech.Recognition;
using System.Speech.Synthesis;

namespace CsharpCode
    public partial class Form1 : Form
        //Creating objects
        SerialPort myPort = new SerialPort();
        SpeechRecognitionEngine re = new SpeechRecognitionEngine();
        SpeechSynthesizer ss = new SpeechSynthesizer(); // When you want program to talk back to you 
        Choices commands = new Choices(); // This is an important class as name suggest we will store our commands in this object
        public Form1()
            //Details of Arduino board
            myPort.PortName = "COM5"; // My Port name in Arduino IDE selected COM5 you need to change Port name if it is different  just check in arduinoIDE
            myPort.BaudRate = 9600;  // This Rate is Same as arduino Serial.begin(9600) bits per second

        // Defined Function processing where main instruction will be executed ! 
        void processing()
            //First of all storing commands
            commands.Add(new string[] { "Blue On", "Red On", "Green On", "Blue Off", "Red Off", "Green Off", "Exit", "All On", "All Off","Arduino Say Good Bye to makers" });

            //Now we will create object of Grammer in which we will pass commands as parameter
            Grammar gr = new Grammar(new GrammarBuilder(commands));

            // For more information about below funtions refer to site
            re.RequestRecognizerUpdate(); // Pause Speech Recognition Engine before loading commands
            re.SetInputToDefaultAudioDevice();// As Name suggest input device builtin microphone or you can also connect earphone etc...
            re.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(re_SpeechRecognized);

        void re_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
                ////For Led State ON 
                // For blue led
                case "Blue On":

                // For red led
                case "Red On":

                // For green led
                case "Green On":
                //For Led State OFF 
                // For blue led
                case "Blue Off":

                // For red led
                case "Red Off":

                // For green led
                case "Green Off":

                //For turning ON all leds at once :)
                case "All On":

                //For turning OFF all leds at once :)
                case "All Off":
                //Program will talk back 
                case "Arduino Say Good Bye to makers":
                    ss.SpeakAsync("Good Bye Makers"); // speech synthesis object is used for this purpose
                // To Exit Program using Voice :)
                case "Exit":
            txtCommands.Text += e.Result.Text.ToString() + Environment.NewLine;// Whenever we command arduino text will append and shown in textbox

        void sendDataToArduino(char character)

        private void btnStop_Click(object sender, EventArgs e)
            //btnStart.Enabled = true;
            btnStop.Enabled = false;
            btnStart.Enabled = true;

        private void btnStart_Click(object sender, EventArgs e)
            btnStop.Enabled = true;
            btnStart.Enabled = false;
            MessageBox.Show("Voice Recognition Started !", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);


Simply follow Schematic and connect components on your breadboard
1 -> First of all connect leds and resistors as shown in diagram
2-> Then start one by one and connect led +ive terminal on same column where resistor is connected to arduino digital pin box
GreenLed +ive terminal to digital Pin 8
RedLed +ive terminal to digital Pin 9
BlueLed +ive terminal to digital Pin 10
3-> At last connect Ground from arduino to leds -ive terminal using jumper wire as shown in diagram



Jalal mansoori
Jalal Mansoori
  • 5 projects

Additional contributors

  • Shared article on turning on and off led using c# and arduino most importantly code was simple and easy to understand so that anyone with little bit of knowledge can create new project out of it. by Kishore Chowdary

Published on

September 15, 2018

Members who respect this project

Avatar fofgrbxpczIamgiulyDwmurray57ErospeterNoel 3  8x10 bw 31kDefault555 esr9dzao2aPhoto

and 66 others

See similar projects
you might like

Similar projects you might like

Ultrasonic Security System

Project tutorial by Ivan

  • 170 respects

Turn Lights On When Approaching Home

Project tutorial by Andrei Florian

  • 71 respects

Program MKR Over-the-Air + Goodies: Voice Control, etc.

Project tutorial by Flower Platform

  • 38 respects

Arduino Bluetooth Robot for Android Device

Project showcase by aip06

  • 24 respects

Controlling Arduino by Voice (Say open to light the LED)

Project tutorial by Blue Hybrids

  • 12 respects
Add projectSign up / Login