Alamin Musa Magaga
2 min readMay 17, 2021

--

How To Control LED With Android phone

In this Arduino project, you will learn how to turn on or off LED with your android phone via Bluetooth.

Photo by Sten Ritterfeld on Unsplash

COMPONENTS USED IN THE PROJECT
1-Arduino Uno
2-HC-5 Bluetooth module
3-LED x 2
4-Jumper Wires

SOFTWARE
download the Bluetooth controlled app from the google app play store using the link https://play.google.com/store/apps/details?id=gr.fundroid3000.bluetootharduino&hl=en&gl=US

DIAGRAM

Magtech Dihub

STEP 1: connect the Bluetooth module to the Arduino.

Magtech Dihub

1-connect RX of Bluetooth module to the TX of the Arduino.
2-connect TX of Bluetooth module to the RX of the Arduino.
3-connect GND of Bluetooth module to the GND of the Arduino.
4-connect VCC of Bluetooth module to the 5v of the Arduino.

STEP 2: connect LED to the Arduino.

Magtech Dihub

place your two LEDs into the breadboard, connect the positive terminal of one of the LEDs to pin 5, and the other terminal to pin 6 of the Arduino Uno, also connect the negative terminals of the LED’s to the GND of the Arduino.

STEP 3: upload the code in Arduino IDE
now, write and upload this code in the Arduino IDE

int pin1=5;
int pin2=6;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(pin1,OUTPUT);
pinMode(pin2,OUTPUT);
}
char data;

void loop() {
// put your main code here, to run repeatedly:
if(Serial.available()>0){
data=Serial.read();

if (data=='a'){
digitalWrite(pin1,HIGH);
}
else if (data=='1'){
digitalWrite(pin1,LOW);
}
else if (data=='b'){
digitalWrite(pin2,HIGH);
}
else if (data=='2'){
digitalWrite(pin2,LOW);
}
}
}

or download the source code from the Github repo https://github.com/alaminmagaga/Arduino-LED-Source-code

warning:
disconnect the Bluetooth module from the Arduino before uploading the code.

Video Demonstration

https://www.youtube.com/watch?v=8ZLVHrCddB4&t=44s

--

--

Alamin Musa Magaga

Data Scientist | Developer | Embedded System Engineer | Zindi Ambassador | Omdena Kano Lead | Youth Opportunities Ambassador | CTO YandyTech