I want to control an LED from the phone. I used MIT App inventor 2 to develop the phone app. I am using Bluetooth technology for the communication between arduino and the phone. The used module is shown in the link below
https://learn.sparkfun.com/tutorials/using-the-bluesmirf
The module connected to the phone, however I did not view any serial data at the serial port and the LED is not controlled.
Please check below arduino code:
#include <SoftwareSerial.h>
SoftwareSerial bluetooth(10, 11); // TX, RX
String readString;
void setup() {
bluetooth.begin(9600);
bluetooth.println("Bluetooth On");
pinMode(13, OUTPUT);
}
void loop() {
while (bluetooth.available())
{
delay(3);
char data=bluetooth.read();
readString += data;
}
if (readString.length() > 0)
{
Serial.println(readString);
if (readString=="on")
{
digitalWrite(13,HIGH);
}
if (readString=="off")
{
digitalWrite(13,LOW);
}
readString ="";
}
}