I want to control Servo motor using sensors as well as using Android App.

I want to control servo motor using sensors as well as using Android App by Bluetooth.
Here iam using IR sensors for controlling servo motor, but also want to use Android app.

My motive is create two mode, 1.Automatic 2.Android
to control servo motor automatically by IR
and to control servo motor by App.

I can create this both cases separately, but can't implement in one program.

am new to arduino, please can any one help me by providing arduino code ??

I can create this both cases separately, but can't implement in one program.

Please post what you tried along with any compilation errors. If the code compiles OK please describe what it does that is wrong

This is code I have done with it, but this is not working.
When i am sending message from android, it will shows no Bluetooth device connected. but Bluetooth is connected, I have tried different simple programs of Bluetooth .

Here Iam making automatic and android based railway level control..... please help me by giving correct code or improve this code.

#include <EEPROM.h>
#include <Servo.h>
#include <SoftwareSerial.h>

Servo myservo1;
Servo myservo2;

int TX = 10;
int RX = 11;

int sensor1 = A0;
int sensor2 = A1;
int sensor3 = A2;
int sensor4 = A3;
int pos = 0;

int GLED1 = 8;
int RLED1 = 9;

int sensor5=2;

int buzzer = 12;

SoftwareSerial HC_05(TX, RX);

void setup() {

myservo1.attach(5);
myservo2.attach(6);

pinMode(sensor1,INPUT);
pinMode(sensor2,INPUT);
pinMode(sensor3,INPUT);
pinMode(sensor4,INPUT);

pinMode(buzzer,OUTPUT);

pinMode(sensor5,INPUT);

EEPROM.write(0, 0);
EEPROM.write(1, 0);

Serial.begin(9600);
HC_05.begin(9600);

}

void loop() {

char data;
/----------------------------------------------Signalling System 1----------------------------------/

if(digitalRead(sensor5)==LOW) //Check the sensor output
{
digitalWrite(9, HIGH); // set the Red LED on
digitalWrite(8,LOW);

}
if(digitalRead(sensor5)==HIGH)
{
digitalWrite(8, HIGH); // set the Green LED on
digitalWrite(9,LOW);
}

/--------------------------------------------Automatic Railway Level Gate Control--------------------/

if(HC_05.available()> 0 )
{
int value = HC_05.read();

if(value=='a')//for automode
{
if (EEPROM.read(1)==0 || EEPROM.read(0)==1){

while (analogRead(sensor1)>500){
if (analogRead(sensor2)>500){
if (EEPROM.read(1)!=1){ EEPROM.write(1, 1);}
if (EEPROM.read(0)!=1){ EEPROM.write(0, 1);}

// Serial.println("X");
delay(100);
}}

while (analogRead(sensor3)>500){
if (analogRead(sensor4)>500){
if (EEPROM.read(1)!=1){ EEPROM.write(1, 1);}
if (EEPROM.read(0)!=1){ EEPROM.write(0, 1);}
// Serial.println("Y");
delay(100);
}}
}

if (EEPROM.read(1)==1 || EEPROM.read(0)==1){

while (analogRead(sensor2)>500){
if (analogRead(sensor1)>500){
if (EEPROM.read(1)!=0){ EEPROM.write(1, 0);}
if (EEPROM.read(0)!=1){ EEPROM.write(0, 1);}

//Serial.println("Z");
delay(100);
}}

while (analogRead(sensor4)>500){
if (analogRead(sensor3)>500){
if (EEPROM.read(1)!=0){ EEPROM.write(1, 0);}
if (EEPROM.read(0)!=1){ EEPROM.write(0, 1);}
//Serial.println("A");
delay(100);
}}
}

if (EEPROM.read(1)==1){ //Gate open
if (pos != 90){
for (pos = 0; pos < 90; pos += 1){
myservo1.write(pos);
myservo2.write(pos);
// Serial.println(pos);
digitalWrite(buzzer,HIGH);
delay(10);
digitalWrite(buzzer,LOW);
delay(10);
}}

//Serial.println("Gate Opend");
digitalWrite(buzzer,LOW);
if (EEPROM.read(0)!=0) {EEPROM.write(0, 0); /Serial.println("OK");/}
}

if (EEPROM.read(1)==0){ //Gate close
if (pos != 0){
for (pos = 90; pos > 0; pos -= 1){
myservo1.write(pos);
myservo2.write(pos);
digitalWrite(buzzer,HIGH);
delay(10);
digitalWrite(buzzer,LOW);
delay(10);
}}

//Serial.println("Gate Closed");
if (EEPROM.read(0)!=0) {EEPROM.write(0, 0); Serial.println("OK");}
}

}
else
if(data=='m')//Manual Mode on
{
if(data=='u')//for 90 degree
{ Serial.println(data);
myservo1.write(90);
myservo2.write(90);
}
if(data=='d')//for 0 degree
{
{ Serial.println(data);
myservo1.write(90);
myservo2.write(90);
}
}
}
}
}

SoftwareSerial.h and Servo.h are not compatible. They both use Timer1. You could try using ServoTimer2.h or connecting your Bluetooth via hardware Serial.

I've not looked at the rest of your code because it won't do anything useful until you sort out that basic incompatibility.

Steve

This is code I have done

Why is it that a;most nobody reads and takes notice of read this before posting a programming question at the top of the thread list ?

this doesn't work sir

mehulraj:
this doesn't work sir

What doesn't work ?