Control Your Multicolor LED Using Smartphone!!

by halim930112 in Circuits > Arduino

9658 Views, 192 Favorites, 0 Comments

Control Your Multicolor LED Using Smartphone!!

IMG_20151219_112006.jpg

Hello, everybody!! I am back this time to share with you an instructables I made during the weekend. I hope everybody is fine and Let's get to the first step shall we?

STEP 1: Items Needed

IMG_20151219_112006.jpg

Hardware:

HC-06 Bluetooth Module

RGB/Multicolor LED

Arduino UNO

330ohm resistor x 3

male to male Jumper

Software:

Arduino IDE

MIT app inventor 2

STEP 2: Assemble the Circuit

RGB_LED_Bluetooth_bb.jpg

Assemble the circuit as shown in the image. The circuit was designed by using Fritzing.The RGB/multicolor LED is common anode by the way.After the circuit assembly, we'll go the coding part. The coding part is divided into 2, Arduino IDE and MIT app inventor 2. Let's see the MIT appinventor 2 part first.

Step3: MIT App Inventor 2 Code Block

MIT app inventor2rgb.jpg
MIT app inventor2rgb1.jpg

These are the design and the code blocks for the MIT app inventor 2. Make sure to follow the code blocks carefully as any mistake will cause more hassle. After the MIT code block, we are going to see the code for the Arduino section.

Step4: the Arduino Code

int redPin = 11;// red pin position

int greenPin = 10;// green pin position

int bluePin = 9;// blue pin position

int value = 0;//initial serial read value

void setup() {

Serial.begin(9600);//this is important. the baud rate between arduino bluetooth and smartphone

pinMode(redPin, OUTPUT);

pinMode(greenPin, OUTPUT);

pinMode(bluePin, OUTPUT); //all the RGB pin were declared as output

}

void loop() {

while(Serial.available()){//if serial reading is available

delay(1000);//delay for a second, avoid overloading

value = Serial.read(); //value = serial value(led value)

Serial.print(value);//print the serial value

Serial.println();

if (value == 1)//the value which corresponds the MIT appinventor 2 byte sent. change accordingly to your own value here and MIT appinventor 2 code block

{

setColor(200, 100, 200); //turqoise

}

if(value == 2) {

setColor(0, 0, 255); // green

}

if(value == 3) {

setColor(255, 255, 0); // blue

}

} }

void setColor(int red, int green, int blue) {

analogWrite(redPin, red);

analogWrite(greenPin, green);

analogWrite(bluePin, blue);//set the colors for the RGB }

STEP 5:Test It!!

Download the apk file from the MIT appinventor and upload it into your smartphone. Then, upload the arduino code into your arduino with bluetooth. Then, its testing time!!! The testing video of this experiment is at https://youtu.be/heoPw4e_4z8