ERROR IN HUMANOID ROBOT CODE

Can anyone rectify this error and help me with this code . Please !!!

The error is “blue is not defined in this scope”.

Below is code along with it’s library.

Please correct it and reply.

VarSpeedServo-master.zip (23.9 KB)

arduino_voice.ino (6.4 KB)

rk5849c:
Can anyone rectify this error and help me with this code . Please !!!!!!!!!!!!!!!!!!!!!!

What error?

You need to post the error message.

And don't post your email address in a public Forum unless you enjoy being flooded with SPAM.

Nobody here is going to send you a response using email. You have to come back and read the Forum.

...R

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

blue is what you are calling your BT channel, however you need to use Software Serial library if you are going to use it with a UNO and not use pin0 and pin1 of the serial monitor.

This may help;
https://www.arduino.cc/en/Reference/SoftwareSerial

If a Mega, use one of the other hardware UARTs.

Thanks.. Tom.. :slight_smile:

[OT]

I would have expected an error like "SHIFT KEY/CAPS LOCK FAILURE DETECED."

[/OT]

Seems fairly clear. It's telling you that you are trying to use something called blue, as in blue.begin(9600). But you have never defined anything called blue. We can only guess what blue is supposed be and where and how it might be connected. The compiler won't guess, you have to tell it.

Steve

///////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////// Android Controlled Biped - Test Code 1
////////////  Sequence like walk, dance etc.
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// import the serial library1
#include <VarSpeedServo.h>                    // varialble speed control servo libarary                           // Assigning Integer
VarSpeedServo RU;                          // Ininitalizling servo objects
VarSpeedServo RM;
VarSpeedServo RL;
VarSpeedServo LU;
VarSpeedServo LM;
VarSpeedServo LL;


// Added these two lines to work around undefined names.
// Compiles with only warnings for Arduino Leonardo. (Arduino Mega should also work)
#define blue Serial1  
String voice;


void setup()
{
  blue.begin(9600);                      // Enabling Serial Communication for Bluetooth (HC-05)
  Serial.begin(9600);                   // Enabling Serial communcication for serial monitoring of data
  LU.attach(3);                        // Attaching Servo motors
  LM.attach(5);
  LL.attach(6);
  RU.attach(9);
  RM.attach(10);
  RL.attach(11);


  LU.write(90);           // Initializing all motors to position
  delay(200);
  LM.write(90);
  delay(200);
  LL.write(90);
  delay(200);
  RU.write(90);
  delay(200);
  RM.write(90);
  delay(200);
  RL.write(90);
  delay(200);
  delay (5000);
  int b = 60;
}


void loop()
{
  while (blue.available())                // Checking for serial communcation of bluetooth data
  {
    char c = blue.read();      // Geting values in a varialbe
    delay(10);
    if (c == '#')
    {
      break;
    }
    voice += c;
  }
  if (voice.length() > 0)
  {
    // prepare for next data ...
    Serial.println(voice);


    if (voice == "*forward")
    {
      Serial.println("moving forward");
      walk ();
    }
    else if (voice == "*stop")
    {
      Serial.println("Stopping");
      halt ();
    }


    else if (voice == "*kick")
    {
      Serial.println("Kicking the ball");
      kick ();
    }
    else  if (voice == "*welcome")
    {
      Serial.println("Greeting you all");
      welcome ();
    }
    else if (voice == "*left")
    {
      Serial.println("Turning Left");
      left ();
    }
    else if (voice == "*right")
    {
      Serial.println("Turning Right");
      right ();
    }
    else
    {
      Serial.println("No command found");
      LU.write(90);           // Initializing all motors to position
      delay(200);
      LM.write(90);
      delay(200);
      LL.write(90);
      delay(200);
      RU.write(90);
      delay(200);
      RM.write(90);
      delay(200);
      RL.write(90);
      delay(200);
    }
    voice = "";       // resetting string to get fresh voice command
  }
}


void walk ()
{
  for (int i = 0; i < 3; i++)
  {
    LL.write(60, 50, true);
    RL.write(60, 50, true);
    //RM.write(120,50,true);
    //delay (1000);
    // LL.write(60,50,true);
    RU.write(110, 40, true);
    LM.write(110, 50, true);
    // RU.write(90,50,true);
    // LU.write(90,50,true);
    // RM.write(90,20,true);
    RL.write(90, 50, true);
    LL.write(90, 50, true);
    delay(1000);
    RL.write(125, 30, true);
    LL.write(120, 100, true);
    int a = RU.read ();
    RU.write(a - 10, 50, true);
    LM.write(90, 50, true);
    LU.write(70, 50, true);
    RU.write(60, 50, true);
    //LU.write(60,50,true);
    RM.write(60, 50, true);
    LL.write(90, 50, true);
    RL.write(90, 50, true);
    delay(1000);
    // b= RM.read();
    LL.write(60, 50, true);
    RL.write(60, 50, true);
    RM.write(90, 50, true); // updation
    LU.write(90, 50, true); // updation
  }
  LU.write(90);           // Initializing all motors to position
  delay(200);
  LM.write(90);
  delay(200);
  LL.write(90);
  delay(200);
  RU.write(90);
  delay(200);
  RM.write(90);
  delay(200);
  RL.write(90);
  delay(200);
  //  delay (1000);


}


void halt ()
{
  LU.write(90);
  delay(200);
  LM.write(90);
  delay(200);
  LL.write(90);
  delay(200);
  RU.write(90);
  delay(200);
  RM.write(90);
  delay(200);
  RL.write(90);
  delay(200);
}


void kick ()
{
  LU.write(90);
  delay(200);
  LM.write(90);
  delay(200);
  LL.write(90);
  delay(200);
  RU.write(90);
  delay(200);
  RM.write(90);
  delay(200);
  RL.write(90);
  delay(200);


  LL.write(60, 100, true);
  RL.write(60, 100, true);


  RM.write(130, 100, true);
  // LL.write(60,50,true);
  RL.write(90, 10, true);
  RM.write(90, 10, true);
  RU.write(60, 10, true);
  RU.write(120, 50, true);
  delay(500);
}
void welcome ()
{
  LU.write(90);
  delay(200);
  LM.write(90);
  delay(200);
  LL.write(90);
  delay(200);
  RU.write(90);
  delay(200);
  RM.write(90);
  delay(200);
  RL.write(90);
  delay(200);


  RM.write(60);//,50,true);
  LM.write(120);//,100,true);
  delay(100);
  RM.write(45);
  LM.write(135);
  delay(100);
  RM.write(30);//,50,true);
  LM.write(150);//,100,true);
  delay(500);
  RM.write(60);
  LM.write(120);
  delay(100);
  RM.write(90);
  LM.write(90);
  delay(2000);
}


void left()
{
  LU.write(90);
  delay(200);
  LM.write(90);
  delay(200);
  LL.write(90);
  delay(200);
  RU.write(90);
  delay(200);
  RM.write(90);
  delay(200);
  RL.write(90);
  delay(200);
  for (int i = 0; i < 3; i++)
  {
    RL.write(120, 50, true);
    LL.write(120, 50, true);
    LU.write(70, 50, true);
    //RU.write(60,50,true);
    //LU.write(60,50,true);
    RM.write(70, 50, true);
    LL.write(90, 50, true);
    RL.write(90, 50, true);
    delay(500);
    LU.write(110, 50, true);
  }
  RL.write(120, 50, true);
  LL.write(120, 50, true);
  LU.write(90, 50, true);
  RL.write(90, 50, true);
  LL.write(90, 50, true);


}


void right ()
{
  LU.write(90);
  delay(200);
  LM.write(90);
  delay(200);
  LL.write(90);
  delay(200);
  RU.write(90);
  delay(200);
  RM.write(90);
  delay(200);
  RL.write(90);
  delay(200);


  for (int i = 0; i < 3; i++);
  {
    LL.write(60, 50, true);
    RL.write(60, 50, true);
    //RM.write(120,50,true);
    //delay (1000);
    // LL.write(60,50,true);


    RU.write(110, 40, true);


    LM.write(110, 50, true);
    // RU.write(90,50,true);
    // LU.write(90,50,true);
    // RM.write(90,20,true);
    RL.write(90, 50, true);
    LL.write(90, 50, true);
    delay(400);
    RU.write(70, 50, true);
  }
  LL.write(60, 50, true);
  RL.write(60, 50, true);
  RU.write(90, 50, true);
  LL.write(60, 50, true);
  RL.write(60, 50, true);
}