Voice command to control LED with Arduino


Voice command to control LED

  
Its strange and seems unrealistic when voice recognised by bulb/LED it reacts to it by turning ON or OFF but now lets make this unrealistic thing work or act according to what we say by Arduino is an open-source platform used for building electronics projects. Arduino consists of both a physical programmable circuit board (often referred to as a microcontroller) and a piece of software, or IDE (Integrated Development Environment) that runs on your computer, used to write and upload computer code to the physical board.
The Arduino platform has become quite popular with people just starting out with electronics, and for good reason. Unlike most previous programmable circuit boards, the Arduino does not need a separate piece of hardware (called a programmer) in order to load new code onto the board -- you can simply use a USB cable. Additionally, the Arduino IDE uses a simplified version of C++, making it easier to learn to program. Finally, Arduino provides a standard form factor that breaks out the functions of the micro-controller into a more accessible package.

So by using this we will control our LED 

Components Required for our Project

1. LED (3 any color)

2. Arduino Uno with cable

3. Bluetooth module HC-05

4.  Jumper Wires  
  • Male to Male
  • Male to Female
5. This Download this App to control the LED using smart phone

Connection of Arduino-LED



Tap to enlarge image



So here the  is the code :

NOTE:

Once the code is uploaded connect your Bluetooth to this App and then give voice command from the code to smartphone to turn ON/OFF the LED

String voice;
int RED = 9;//you can connect LED any pins
int GREEN = 10;
int BLUE = 11;
void RedOn(){
digitalWrite (RED, HIGH);
}
void RedOff(){
digitalWrite (RED, LOW);
}
void GreenOn(){
digitalWrite (GREEN, HIGH);
}
void GreenOff(){
digitalWrite (GREEN, LOW);
}
void BlueOn(){
digitalWrite (BLUE, HIGH);
}
void BlueOff(){
digitalWrite (BLUE, LOW);
}
void allon() {
digitalWrite (RED, HIGH);
digitalWrite (GREEN, HIGH);
digitalWrite (BLUE, HIGH);
}
void alloff() {
digitalWrite (RED, LOW);
digitalWrite (GREEN, LOW);
digitalWrite (BLUE, LOW);
}
void setup() {
Serial.begin(9600);
pinMode(RED, OUTPUT);
pinMode(GREEN, OUTPUT);
pinMode(BLUE, OUTPUT);
}
void loop() {
while(Serial.available()) {
delay(10);
char c=Serial.read();
if(c=='#')
{break; }
voice += c;
}
if (voice.length() > 0) {
Serial.println(voice);
if (voice == "on" || voice == “Alexa all”)
{
allon() ;
}
else if (voice == "off" || voice==“Alexa all off")
{
alloff() ;
}
else if(voice =="red" || voice ==“Alexa red on"){
RedOn();
}
else if(voice =="red off"){
RedOff();
}
else if(voice =="green" || voice ==“Alexa green on"){
GreenOn();
}
else if( voice =="green off" ){
GreenOff();
}
else if(voice =="blue" || voice ==“Alexa blue on"){
BlueOn();
}
else if(voice ==“Alexa blue off"){
BlueOff();
}
voice="";
}
}

My Instagram

Made with by Pi-girl | Copyright © 2020 Pi-girl