Control RGB Led Using Smartphone By Arduino and Bluetooth By Technoesolution | #arduinoprojects

January 30, 2022


Description 

This article will show you how to "Control RGB LED Using Bluetooth And Arduino With the Help of Smartphone App" in a few steps. First, collect all the material which is listed below. Refer to the circuit diagram to make connections.

Watch out the video If reading bores you.

If you got this article helpful, Subscribe to our blog & youtube channel for more interesting projects.

Material Required:- 

(Following links are affiliated links, If you buy from this link we will get some bonus from it.)

Sr.No

Product Name

Quantity

Best Buy Link

1

Arduino Nano

1

https://amzn.to/3tHvCjk

2

Breadboard + Jumper Wires

1

https://amzn.to/3fIWUO5

3

RGB LED

1

https://amzn.to/3GMsJSd

4

Resistor (470E)

1

https://amzn.to/35eClnu

5

HC-05 Bluetooth Module

1

https://amzn.to/3nGX8d0

Circuit Diagram:-


Refer to the above circuit diagram to make connections.

Arduino Code:-

/*
   Hello guys welcome back to "Techno-E-Solution"
   Project Name:- Control RGB Led Using Smartphone By Arduino and Bluetooth
   Project Video:- https://youtu.be/Rj1dEKGPtl8
*/

#include <SoftwareSerial.h>
#include <Wire.h>
SoftwareSerial mySerial(0,1); // RX and TX pins
int PIN_RED = 9;
int PIN_GREEN = 10;
int PIN_BLUE = 11;
String RGB = "";
String RGB_Previous = "255.255.255";
String ON = "ON";
String OFF = "OFF";
boolean RGB_Completed = false;
void setup()
{
pinMode (PIN_RED, OUTPUT);
pinMode (PIN_GREEN, OUTPUT);
pinMode (PIN_BLUE, OUTPUT);
Serial.begin(9600);
mySerial.begin(9600);
RGB.reserve(30);
}
void loop()
{
while(mySerial.available())
{
char ReadChar = (char)mySerial.read();
if(ReadChar == ')')
{
RGB_Completed = true;
}else{
RGB += ReadChar;
}
}
if(RGB_Completed)
{
Serial.print("RGB:");
Serial.print(RGB);
Serial.print(" PreRGB:");
Serial.println(RGB_Previous);
if(RGB==ON)
{
RGB = RGB_Previous;
Light_RGB_LED();
}
else if(RGB==OFF)
{
RGB = "0.0.0";
Light_RGB_LED();
}else{
Light_RGB_LED();
RGB_Previous = RGB;
}
RGB = "";
RGB_Completed = false;
}
}
void Light_RGB_LED()
{
int SP1 = RGB.indexOf(' ');
int SP2 = RGB.indexOf(' ', SP1+1);
int SP3 = RGB.indexOf(' ', SP2+1);
String R = RGB.substring(0, SP1);
String G = RGB.substring(SP1+1, SP2);
String B = RGB.substring(SP2+1, SP3);
Serial.print("R=");
Serial.println( constrain(R.toInt(),0,255));
Serial.print("G=");
Serial.println(constrain(G.toInt(),0,255));
Serial.print("B=");
Serial.println( constrain(B.toInt(),0,255));
analogWrite(PIN_RED, (R.toInt()));//comment if colors are inverted
analogWrite(PIN_GREEN, (G.toInt()));//and uncomment part below.
analogWrite(PIN_BLUE, (B.toInt()));
analogWrite(PIN_RED, (255-R.toInt()));//uncomment if colors are inverted
analogWrite(PIN_GREEN, (255-G.toInt()));//and comment above part.
analogWrite(PIN_BLUE, (255-B.toInt()));
}


You can Buy me a coffee If you got this article helpful.