Introduction

In this article, I will explain how to turn LED ON/ OFF in Bluetooth using Android Apps In Arduino Mega 2560. In the setup, we can easily connect it through an Android app. LED turns on when the ON button is pressed, and off when the Off button is pressed.
Parts of list
Software required
MIT App Inventor 2
Connection:
Step 1:
Connection from the Bluetooth (HC05) to the Arduino Mega 2560.
Figure1: Bluetooth(HC05)
Step2: Connection from the LED to the Arduino Mega2560.
Software steps:
MIT App Window
MIT App window
Programming
  1. int led - turn - on - off - in -bluetooth - using - android - apps - in -arduinompin = 13;
  2. String readString;
  3. void setup()
  4. {
  5. Serial.begin(9600); // Baud Rate
  6. pinMode(led - turn - on - off - in -bluetooth - using - android - apps - in -arduinompin, OUTPUT);
  7. }
  8. void loop()
  9. {
  10. while (Serial.available()) //Send data only when you receive data
  11. {
  12. delay(4); //delay time
  13. char c = Serial.read();
  14. readString += c;
  15. }
  16. if (readString.length() > 0)
  17. {
  18. Serial.println(readString);
  19. if (readString == "ON")
  20. {
  21. digitalWrite(led - turn - on - off - in -bluetooth - using - android - apps - in -arduinompin, HIGH); // LED ON
  22. }
  23. if (readString == "OFF")
  24. {
  25. digitalWrite(led - turn - on - off - in -bluetooth - using - android - apps - in -arduinompin, LOW); //LED OFF
  26. }
  27. readString = "";
  28. }
  29. }
Explanation
Output
Figure 3: Output
Read articles on Arduino: