Voice Control RGB Led Using Bluetooth & Arduino

by rayankiwan63 in Circuits > Arduino

45 Views, 0 Favorites, 0 Comments

Voice Control RGB Led Using Bluetooth & Arduino

vlcsnap-2018-12-19-11h56m51s072_3q1zcLuFiB.jpg

Simple voice controlled RGB Led colour using Arduino and Android device connected via Bluetooth

Components Needed

1-Arduino

2-RGB led

3-bluetooth

4-breadboard

5- wires

download AMR-VOICE APP FROM APP STORE ON YOUR PHONE

Circuit Diagram

voice control rgb.jpg

CODE

Rayan Kiwan

//Coded By: rayan kiwan(2/7/21) //Voice Activated Arduino (Bluetooth + Android) //Feel free to modify it but remember to give credit

String voice;

int led1 = 10; //Connect LED 1 To Pin #10

int led2 = 9; //Connect LED 2 To Pin #9

int led3 = 8; //Connect LED 3 To Pin #8

//--------------------------Call A Function-------------------------------//

void blue(){

digitalWrite(led1, HIGH);

digitalWrite(led2, LOW);

digitalWrite(led3, LOW); }

void green(){

digitalWrite(led1, LOW);

digitalWrite(led2, HIGH);

digitalWrite(led3, LOW); }

void red(){

digitalWrite(led3, HIGH);

digitalWrite(led2, LOW);

digitalWrite(led1, LOW); }

void yellow(){

digitalWrite(led3, HIGH);

digitalWrite(led2, HIGH);

digitalWrite(led1, LOW); }

void white(){

digitalWrite(led3, HIGH);

digitalWrite(led2, HIGH);

digitalWrite(led1, HIGH); }

void black(){

digitalWrite(led3, LOW);

digitalWrite(led2, LOW);

digitalWrite(led1, LOW); }

//-----------------------------------------------------------------------//

void setup() {

Serial.begin(9600);

pinMode(led1, OUTPUT);

pinMode(led2, OUTPUT);

pinMode(led3, OUTPUT); }

//-----------------------------------------------------------------------//

void loop() {

while (Serial.available()){ //Check if there is an available byte to read

delay(10); //Delay added to make thing stable

char c = Serial.read(); //Conduct a serial read

if (c == '#') {break;} //Exit the loop when the # is detected after the word

voice += c; //Shorthand for voice = voice + c }

if (voice.length() > 0) { Serial.println(voice);

//-----------------------------------------------------------------------// //----------Control Multiple Pins/ LEDs----------// if(voice == "*blue") {blue();}

else if(voice == "*green"){green();}

else if(voice == "*red") {red();}

else if(voice == "*yellow") {yellow();}

else if(voice == "*black") {black();}

else if(voice == "*white") {white();} voice="";}} //Reset the variable after initiating