Controlling an LED wireless using Andriod App, Bluetooth HC-05, and Arduino Uno
This post is about controlling an LED wireless using Andriod App, Bluetooth HC-05, and Arduino Uno.
How does it work
After connecting the circuit and pairing the App with Bluetooth. You send data from App which is received by the Bluetooth (either 1 or 0). This data is sent to LED by the Arduino. If data is 1 the LED goes on, if data is 0 the LED goes off.
You need also an android phone to download LED controller Bluetooth App.
As discussed in the previous post, we need a resistor to control the amount of current going through the LED.
Circuit Diagram/ How to connect them?
LED pin 1 to the Resistor pin1
LED pin2 to the Arduino GND
Arduino Digital pin13 to the Resistor pin2
Bluetooth VCC pin to the Arduino 5v
Bluetooth GND pin to the Arduino GND
Bluetooth TXD pin to the Arduino Digital pin RX0 (0)
Bluetooth RXD pin to the Arduino Digital pin TX0 (1)
TX is a transmitter which sends data and RX is the receiver which receives data from the transmitter. So make sure you connect the transmitter (TX) to (RX)
// Code to control the Arduino and LED using Andriod App by wireless Bluetooth HC-05
char data = 0; //Variable for storing received data
Serial.begin(9600); //Sets the data rate in bits per second (baud) for serial data transmission
pinMode(13, OUTPUT); //Sets digital pin 13 as output pin
if(Serial.available() > 0) // Send data only when you receive data:
data = Serial.read(); //Read the incoming data and store it into variable data
Serial.print(data); //Print Value inside data in Serial monitor
Serial.print(“\n”); //New line
if(data == ‘1’) //Checks whether value of data is equal to 1
digitalWrite(13, HIGH); //If value is 1 then LED turns ON
else if(data == ‘0’) //Checks whether value of data is equal to 0
digitalWrite(13, LOW); //If value is 0 then LED turns OFF
After uploading the code to Arduino, Open the serial monitor which is found in the top right corner. (Make sure you have the right port selected for the Arduino as discussed in the first post). Pair the App with the bluetooth. The results should show LED blinks on and off. If you press ON from the Andriod App the LED should light, if you press OFF the LED light should turn off.
Controlling an LED wireless with Arduino can help us in many other complicating projects where you can control a moving car or a robot. Please stay tuned for other projects.
For more details and the sources of this post please visit the post made by Mayoogh Girish on Interface an Android smartphone with an Arduino via Bluetooth to control an LED from your phone.