LED ON/OFF using Android with Arduino through Bluetooth


Required Parts:
Hardware:
1. Arduino Uno
2. Android Phone
3. HC-05 Bluetooth
4. 5mm LED
5. 1k Resistor
6. jumper wires

Software:
1. ArduinoIDE
2. MIT App Inventor
3. Android App .APK file:https://drive.google.com/file/d/0B9ar1gsIgfkXazdJX1Y3clI4WFU/view


Arduino Code:
int ledPin = 2;
String readString;

void setup() {
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT); 
}

void loop() {
  while (Serial.available()) {
    delay(3);  
    char c = Serial.read();
    readString += c; 
  }
  if (readString.length() >0) {
    Serial.println(readString);
    if (readString == "on")     
    {
      digitalWrite(ledPin, HIGH);
    }
    if (readString == "off")
    {
      digitalWrite(ledPin, LOW);
    }
    readString="";
  } 

}


MIT App Inventor Block:
App Screen shot:

No comments:

Post a Comment