Need help for android meet robot

hi need help i using android meet robot that uses bluetooth , my program can say so far ok but the servo motor when say open it moves to a certain angle when say closes it move back, but when i say open it doesn’t moves anymore but say close it moves any solution thank you

#include <Servo.h>
Servo myservo;
#define RELAY1 2 // Arduino Digital I/O pin number
String voice;
int pos = 0;

//--------------------------Call A Function-------------------------------//
void allon(){
digitalWrite(RELAY1,0); // Turns ON Relays 1
Serial.println(“Lights ON”);
delay(2000); ;

}
void blind1(){
for(pos = 0; pos < 180; pos +=5 ) // goes from 0 degrees to 180 degrees
{
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(50); // waits 15ms for the servo to reach the position
}

}

void alloff(){

digitalWrite(RELAY1,1); // Turns Relay Off
Serial.println(“Lights OFF”);
delay(2000);
}

void blind2(){
for(pos = 180; pos > 0; pos-=5) // goes from 180 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(50); // waits 15ms for the servo to reach the position
}
}

void setup(){
//-------( Initialize Pins so relays are inactive at reset)----
Serial.begin(9600);
myservo.attach(9);

digitalWrite(RELAY1, 1);
//—( THEN set pins as outputs )----
Serial.begin(9600);
pinMode(RELAY1, OUTPUT);
delay(4000); //Check that all relays are inactive at Reset
}//–(end setup )—

//-----------------------------------------------------------------------//

//-----------------------------------------------------------------------//
void loop() {
while (Serial.available()){ //Check if there is an available byte to read
delay(10); //Delay added to make thing stable
char c = Serial.read(); //Conduct a serial read
if (c == ‘#’) {break;} //Exit the loop when the # is detected after the word
voice += c; //Shorthand for voice = voice + c
}
if (voice.length() > 0) {
Serial.println(voice);
//-----------------------------------------------------------------------//
//----------Control Multiple Pins/ LEDs----------//
if(voice == “*on”) {allon();} //Turn Off All Pins (Call Function)
else if(voice == “*off”){alloff();} //Turn On All Pins (Call Function)
else if(voice == “*open”){myservo.write(pos);} //Turn Off All Pins (Call Function)
else if(voice == “*close”){blind2();} //Turn On All Pins (Call Function)

voice="";}} //Reset the variable after initiating

for(pos = 0; pos < 180; pos +=5 )  // goes from 0 degrees to 180 degrees

No, it clearly doesn’t.

      delay(50);    // waits 15ms for the servo to reach the position

No, it clearly doesn’t.

}}

Don’t you just hate it when that happens?

PLEASE use code tags when posting code.

what do you mean ??

I mean in the first two things I pointed-out, the comment doesn't match the code, and in the third, you should never have "}}" on the same line - it shows your code formatting is bad.

Code tags are preferred to ensure that the code you post doesn't get mangled by the forum.

if(voice == "*open"){myservo.write(pos);}

What is the value of "pos" here?
Did you mean "blind1();" instead?

hi need help i using android meet robot that uses bluetooth , my program can say so far ok but the servo motor when say open it moves to a certain angle when say closes it move back, but when i say open it doesn’t moves anymore but say close it moves any solution thank you

#include <Servo.h>
Servo myservo;
#define RELAY1 2 // Arduino Digital I/O pin number
String voice;
int pos = 0;

//--------------------------Call A Function-------------------------------//
void lighton()
{
digitalWrite(RELAY1,0); // Turns ON Relay 1
Serial.println(“Lights ON”);
delay(2000);

}
void lightoff()
{

digitalWrite(RELAY1,1); // Turns Relay Off
Serial.println(“Lights OFF”);
delay(2000);
}

void blind1()
{

for(pos = 0; pos < 180; pos +=5 ) // goes from 0 degrees to 180 degrees
{
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(50); // waits 50ms for the servo to reach the position
}

}

void blind2()
{
for(pos = 180; pos > 0; pos-=5) // goes from 180 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(50); // waits 15ms for the servo to reach the position
}

}

void setup(){
//-------( Initialize Pins so relays are inactive at reset)----
Serial.begin(9600);
myservo.attach(9);
digitalWrite(RELAY1, 1); //xheck that all relays are inactive at Reset
//—( THEN set pins as outputs )----
pinMode(RELAY1, OUTPUT);
delay(4000); //C
}//–(end setup )—

//-----------------------------------------------------------------------//

//-----------------------------------------------------------------------//
void loop() {
while (Serial.available()){ //Check if there is an available byte to read
delay(10); //Delay added to make thing stable
char c = Serial.read(); //Conduct a serial read
if (c == ‘#’) {break;} //Exit the loop when the # is detected after the word
voice += c; //Shorthand for voice = voice + c
}
if (voice.length() > 0) {
Serial.println(voice);
//-----------------------------------------------------------------------//
//----------Control Control Pins/ LEDs----------//
if(voice == “*on”) {lighton();} //Turn ON Light (Call Function)
else if(voice == “*off”){lightoff();} //Turn off All Pins (Call Function)
else if(voice == “*open”){myservo.write(pos);} //Turn On Blind All Pins (Call Function)
else if(voice == “*close”){blind2();} //Turn Off Blind (Call Function)

voice="";//Reset the variable after initiating
}
}

#7 below:

http://forum.arduino.cc/index.php/topic,148850.0.html

In your code you have two functions blind1() and blind2()

Now in your loop you have a call to blind2 yet where I'd expect you to call blind1 you don't. Instead you call myservo.write(pos)
From my brief glympse through your code it appears that pos holdes the current position of your servo, so trying to send it there will cause nothing to happen.

Could it be that where you say

  else if(voice == "*open"){myservo.write(pos);}  //Turn On Blind All Pins (Call Function)

You really meant to say

  else if(voice == "*open"){blind1();} //Turn On Blind (Call Function)

I'm just guessing.

Topics merged.

You'll note that the question was answered almost 24 hours ago.

DO NOT CROSS-POST, IT WASTES TIME

AWOL:
Topics merged.

You'll note that the question was answered almost 24 hours ago.

DO NOT CROSS-POST, IT WASTES TIME

AGH WHAT? .. SOOOOOOOOOOOO ANOYING But at least it shows I was on the right track.