Error message with the Serial library

Hello everyone,

I am currently working on a hexapod, which I will drive with an Arduino Mega 2560 and two servo driver boards. After finishing the assembly, I now want to begin with the programing of the walking. I found on the Net a walking algorithm which is suited for the kit I used at the beginning. So I tried to copy and paste the code and imported the different libraries which I downloaded in the constructor website. Then I tried to upload the code on my microcontroller, but I have an error message, which is saying that "Serial2 is not declared in this scope"

I attached the library where the problem comes from with my thread.

After that, I tried to import the SoftwareSerial library, but it still doesn't work. This is why I am asking for your help, if you know some solutions for this problem.

Thank you for reading and I hope you will be able to help me.

CDS5500_2Serials.h (2.55 KB)

CDS5500_2Serials.cpp (9.9 KB)

Code?

@HazardsMind : I attached it with my first post, because it was too long to be pasted in my message.

No, what you attached were the libraries to the sketch, not your actual sketch.

YOU REALLY NEED TO POST YOUR CODE... Serial1 is a valid comm port for a Mega... But Not IF you Tried to compile the sketch for an Uno...

Sorry, I did not understand what you meant in your first post.

I attached the two other libraries if it could be necessary, and here is the code itself :

/*
*Sample code for the hexapod robot.
*Author: Danfei Xu
*Created on Aug 9th, 2011
*You must import the below three libraries first.
*/
 
 
#include <CDS5500_2Serials.h>
#include <Hexapod_Servo.h>
#include <ServoConsole.h>
 
 
// Below are the ID arrays of servos. You must set the IDs of the servo according
//to the documents : 
//IDs of the servos of the left front leg: 0, 1, 2 (inner, middle, outer)
//IDs of the servos of the left middle leg: 10, 11, 12(inner, middle, outer)
//IDs of the servos of the left back leg: 20, 21, 22 (inner, middle, outer)
//IDs of the servos of the right back leg: 30, 31, 32(inner, middle, outer)
//IDs of the servos of the right middle leg: 40, 41, 42 (inner, middle, outer)
//IDs of the servos of the right front leg: 50, 51, 52(inner, middle, outer)
int axisA[] = {0, 20, 40};
int axisB[] = {10, 30, 50};
int hipA[] = {1, 21, 41};
int hipB[] = {11, 31, 51};
int legA[] = {2, 22, 32};
int legB[] = {12, 32, 52};
int axis[] = {0, 10, 20, 30, 40, 50};
int hips[] = {1, 11, 21, 31, 41, 51};
int legs[] = {2, 12, 22, 32 ,42, 52};
// servo controller 
ServoConsole console;
 
void setup(){
  Serial.begin(115200); //For printing out data, or debugging.
  Serial2.begin(1000000); // Used for control servos on left side.
  Serial1.begin(1000000);// Used for control servos on right side.
}
 
void loop(){
   console.Move(legs, 6, 170, 511); //Legs move to 170 for standing up
   console.Move(hips,6, 480, 511); // hips move to 480 for standing up
   console.Move(axisA, 3, 130, 511); // axis group A move to 130. Prepare for walking
   console.Move(axisB, 3, 70, 511); // axis group B move 70. Prepare for walking
   delay(1000); // waits for their moving
    
   while(1){
     walk();
     //walking loop
   }
}
 
void walk(){
  delay(500);
  console.MoveUp(hipB, 3, 100, 500); //hips group B move up 100
  console.MoveUp(axisB, 3, 60, 300);// axis group B move forward 60
  console.MoveDown(axisA, 3, 60, 300);// axis group A move backward 60
  delay(500);// waits for movement
  console.MoveDown(hipB, 3, 100, 500);//hips group B move down 100
  delay(500);// waits for movement
  console.MoveUp(hipA, 3, 100, 500);//hips group A move up 100
  console.MoveDown(axisB, 3, 60, 300);// axis group B move backward 60
  console.MoveUp(axisA, 3, 60, 300);// axis group A move forward 60
  delay(500);// waits for movement
  console.MoveDown(hipA,3, 100, 500);//hips group A move down 100
}

Concerning my microcontroller, it actually is an Arduino Mega 2560, so that is why I do not understand where the problem comes from.

Hexapod_Servo.cpp (2.7 KB)

Hexapod_Servo.h (718 Bytes)

ServoConsole.cpp (2.63 KB)

ServoConsole.h (1.82 KB)

What board do you have selected, Wednesday?

Im not too sure about this,

Serial2.begin(1000000); // Used for control servos on left side.
Serial1.begin(1000000);// Used for control servos on right side.

The question is, what is it doing or not doing?