Rf receiver code erorr >> need help

im trying to make rc boat and using 2 nano boards as remote and receiver with 2 Rf 433mhz transceivers .
so i found a code for a car so it seems to be good for me .
the car project that I’m talking about is here …
http://garagelab.com/profiles/blogs/tutorial-ardubottom-rf-link-controlled-robot

the first code for remote is fine .
the problem is in second code

The Robots Sketch

Click here to download ardubottom.h
//Includes

//ardubottom.h contains code necessary for the function of this sketch. 

//You must make sure that it is in the same location as this sketch

#include "ardubottom.h"

//Header necessary to connect to and control our servo.

#include <Servo.h>

//Variable Declarations

//variables representing the gearbox motors output pins, and the position of the servo.

int motA_1 = 2,motA_2 = 3,motB_1 = 4,motB_2 = 5,pos = 90;

//create a servo object

Servo lrservo;

//create a cur_Dir object to represent the direction of our robot

cur_Dir currentDirection;

//Function Prototypes

void MoveGearBox(RobotDirection);

void MoveServo(RobotDirection);

void setup()

{

  //Start the USART so we can receive command from the controller

  Serial.begin(4800);

  //Set the gearbox motors control pins as outputs 

  pinMode(motA_1, OUTPUT);

  pinMode(motA_2, OUTPUT);

  pinMode(motB_1, OUTPUT);

  pinMode(motB_2, OUTPUT);

  //Attach pin 6 to our servo object

  lrservo.attach(6);

  //Write the starting position to the servo object which is 90, half of 180  

  lrservo.write(pos);

  //Set the starting direction to nowhere  

  currentDirection = Nowhere;

}

void loop()

{

  //If there are commands available from the controller

  while(Serial.available() > 0)

  {

    //Check if the command character matches any of the following cases

    switch(Serial.read())

    {

      //If it's 'F'

      case 'F':

        //Set the current direction of the robot to Forward      

        currentDirection = Forward;

        //Stop checking cases        

        break;

      //If it's 'B'        

      case 'B':

        //Set the direction to Backwards      

        currentDirection = Backwards;

        //Stop checking cases

        break;

      //If it's 'L'         

      case 'L':

        //Set the current direction to Left      

        currentDirection = Left;

        //Stop checking cases

        break;

      //If it's 'R'        

      case 'R':

        //Set the current direction to Right      

        currentDirection = Right;

        //Stop checking cases

        break;

      //This case is evaluated if all other cases fail to match        

      default:

        //in which case we set the current direction to Nowhere      

        currentDirection = Nowhere;

        //and finish checking all the cases        

        break;

    }

    //Then we send the current direction to the MoveGearBox function

    MoveGearBox(currentDirection);

    //And the MoveServo function where it will be evaluated and acted upon accordingly    

    MoveServo(currentDirection);

  }

}

void MoveServo(RobotDirection dir)

{

  int servoSpeed = 4;

  //If the direction is Left and we have not yet hit the left bound

  if(dir == Left && pos > 0)

  {

    //then decrease the position of the servo (turn counter-clockwise)

    pos -= servoSpeed;

  }

  //But if the direction is Right and we have not reached the right bound

  else if(dir == Right && pos < 179)

  {

    //increase the position of the servo (turn it clockwise)    

    pos += servoSpeed;

  }

  //Otherwise, dont change the servos position

  else

  {

    //Don't Move

    pos = pos;

  }

  //Now that we have an updated position, send it to the servo.

  lrservo.write(pos);

}

void MoveGearBox(RobotDirection dir)

{

  //If the direction is Forward

  if(dir == Forward)

  {

    //Send a high pulse to motA_1 and motB_1;

    //low pulse to motA_2 and motB_2 to make the gearbox move forward

    digitalWrite(motA_1, HIGH);

    digitalWrite(motA_2, LOW);

    delay(15);

    digitalWrite(motB_1, HIGH);

    digitalWrite(motB_2, LOW);

    delay(15);

  }

  //If the direction is Backwards

  else if(dir == Backwards)

  {

    //Send a high pulse to motA_2 and motB_2;

    //low pulse to motA_1 and motB_1 to make the gearbox move backwards

    digitalWrite(motA_1, LOW);

    digitalWrite(motA_2, HIGH);

    delay(15);

    digitalWrite(motB_1, LOW);

    digitalWrite(motB_2, HIGH);

    delay(15);

  }

  //Otherwise...

  else

  {

    //don't Move    

    digitalWrite(motA_1, LOW);

    digitalWrite(motA_2, LOW);

    digitalWrite(motB_1, LOW);

    digitalWrite(motB_2, LOW);

  }

}

the error was :
Arduino: 1.6.5 (Windows 8.1), Board: “Arduino Nano, ATmega328”

transmitter_rx_final_1:20: error: variable or field ‘MoveServo’ declared void
transmitter_rx_final_1:20: error: ‘RobotDirection’ was not declared in this scope
transmitter_rx_final_1:21: error: variable or field ‘MoveGearBox’ declared void
transmitter_rx_final_1:21: error: ‘RobotDirection’ was not declared in this scope
transmitter_rx_final_1:25: error: ‘cur_Dir’ does not name a type
transmitter_rx_final_1:29: error: variable or field ‘MoveGearBox’ declared void
transmitter_rx_final_1:29: error: ‘RobotDirection’ was not declared in this scope
transmitter_rx_final_1:31: error: variable or field ‘MoveServo’ declared void
transmitter_rx_final_1:31: error: ‘RobotDirection’ was not declared in this scope
transmitter_rx_final_1.ino: In function ‘void setup()’:
transmitter_rx_final_1:61: error: ‘currentDirection’ was not declared in this scope
transmitter_rx_final_1:61: error: ‘Nowhere’ was not declared in this scope
transmitter_rx_final_1.ino: In function ‘void loop()’:
transmitter_rx_final_1:87: error: ‘currentDirection’ was not declared in this scope
transmitter_rx_final_1:87: error: ‘Forward’ was not declared in this scope
transmitter_rx_final_1:99: error: ‘Backwards’ was not declared in this scope
transmitter_rx_final_1:111: error: ‘Left’ was not declared in this scope
transmitter_rx_final_1:123: error: ‘Right’ was not declared in this scope
transmitter_rx_final_1:135: error: ‘Nowhere’ was not declared in this scope
transmitter_rx_final_1:145: error: ‘currentDirection’ was not declared in this scope
transmitter_rx_final_1:145: error: ‘MoveGearBox’ was not declared in this scope
transmitter_rx_final_1:149: error: ‘MoveServo’ was not declared in this scope
transmitter_rx_final_1.ino: At global scope:
transmitter_rx_final_1:155: error: variable or field ‘MoveServo’ declared void
transmitter_rx_final_1:155: error: ‘RobotDirection’ was not declared in this scope
variable or field ‘MoveServo’ declared void

This report would have more information with
“Show verbose output during compilation”
enabled in File > Preferences.

so i need an Expert to try the code if he could as shown in the project site that I mentioned above and guide me throw this project.
notes :
1 i’m sorry i’m very beginner .
2 I’m sorry too for my bad English
Thanks a lot

All the errors would suggest you did not do this step:

//ardubottom.h contains code necessary for the function of this sketch.
 
//You must make sure that it is in the same location as this sketch

#include "ardubottom.h"

i put the sketch with the file ardubottom.h in the same folder from the beginning .
C:\Users\a\Documents\Arduino\ardubottom

Any help please

Any body can test this code and tell me what to do
Really I'm stuck and want to make a boat for my kids and we can't buy an rc controllers .
or any body can help me with a new code for remote and recever codes and a little tutorial please .

it is so hard to solve ?

It is harder to solve because it is not a common library.

I did a quick google search and found it might be better for you to open up the .h file in notepad, and copy it's contents into a new tab in in your sketch, remembering to give it the same name "ardubottom.h".

Also, the person was using IDE version 1.0.5. It might be better for you to temporarily install that version of the IDE.

I do as mr Qdeathstar told me and i have this error
Any Ideas ?

sketch_jul20b:18: error: variable or field 'MoveServo' declared void
sketch_jul20b:18: error: 'RobotDirection' was not declared in this scope
sketch_jul20b:19: error: variable or field 'MoveGearBox' declared void
sketch_jul20b:19: error: 'RobotDirection' was not declared in this scope
sketch_jul20b:23: error: 'cur_Dir' does not name a type
sketch_jul20b:27: error: variable or field 'MoveGearBox' declared void
sketch_jul20b:27: error: 'RobotDirection' was not declared in this scope
sketch_jul20b:29: error: variable or field 'MoveServo' declared void
sketch_jul20b:29: error: 'RobotDirection' was not declared in this scope
sketch_jul20b.ino: In function 'void setup()':
sketch_jul20b:59: error: 'currentDirection' was not declared in this scope
sketch_jul20b:59: error: 'Nowhere' was not declared in this scope
sketch_jul20b.ino: In function 'void loop()':
sketch_jul20b:85: error: 'currentDirection' was not declared in this scope
sketch_jul20b:85: error: 'Forward' was not declared in this scope
sketch_jul20b:97: error: 'Backwards' was not declared in this scope
sketch_jul20b:109: error: 'Left' was not declared in this scope
sketch_jul20b:121: error: 'Right' was not declared in this scope
sketch_jul20b:133: error: 'Nowhere' was not declared in this scope
sketch_jul20b:143: error: 'currentDirection' was not declared in this scope
sketch_jul20b:143: error: 'MoveGearBox' was not declared in this scope
sketch_jul20b:147: error: 'MoveServo' was not declared in this scope
sketch_jul20b.ino: At global scope:
sketch_jul20b:153: error: variable or field 'MoveServo' declared void
sketch_jul20b:153: error: 'RobotDirection' was not declared in this scope

Any Ideas ?

I have an idea that you should post a link to the library, the changes you made, and the sketch that is causing the errors. Otherwise, you are wasting our time.

Please post your working code.
If it contains #include “ardubottom.h” it should be easy to cut and paste your NON working code into it.
PS It is not necessary to apologize for your English, it may not look like it, but are among friends who understand.

The code in the link in my first post .
The transmitter code is fine but the recever code get me mad .
I'm an ammeter in arduino
I didn't make any changes in it
I'm just copy it and past but I didn't success and have errors and I'm Stuck
Could you please make it work and send it to me .
And I'm very sorry for your time but my son is very upset and I have nothing to do for him in his boat project becose in my country the remote control and recever is very expensive for me and not allowed to import from outside .
So I told him we can build it with arduino and bought the hardware with my little money and now I almost lose my money coz this code .
So any help in this code or any other code .
And I apologize for your time and thank for every body who's trying to help me .

I'm an ammeter in arduino

An ammeter? Does that mean that you are current?

I didn't make any changes in it

You were told to make some changes, in some code. Either you did, and you need to post the code, or you didn't and you are wasting our time. Which is it?

this is my code

ardubottom.h (162 Bytes)

Recever_code.ino (4.14 KB)

When I wrote ardubottom correctly, your code compiles.

#ifndef _ADRUBOTTOM_H
#define _ARDUBOTTOM_H
typedef enum {
      Nowhere,
      Forward,
      Backwards,
      Left,
      Right
} RobotDirection, cur_Dir;
#endif

Oh, and ardubottom needs to be spelled consistently.
The include guard needs to involve ifndef, not ifdef.

The list of values is defined in curly braces, not parentheses.

Sorry I have a problem I would like to manage the brightness of an LED as I do ??

I tre to do a Lot of sketch but a my friend Tell me there is an error with the timer so some one have an idea?

saifooon:
im trying to make rc boat and using 2 nano boards as remote and receiver with 2 Rf 433mhz transceivers .
so i found a code for a car so it seems to be good for me .
the car project that I’m talking about is here …
http://garagelab.com/profiles/blogs/tutorial-ardubottom-rf-link-controlled-robot

the first code for remote is fine .
the problem is in second code

The Robots Sketch

Click here to download ardubottom.h
//Includes

//ardubottom.h contains code necessary for the function of this sketch.

//You must make sure that it is in the same location as this sketch

#include “ardubottom.h”

//Header necessary to connect to and control our servo.

#include <Servo.h>

//Variable Declarations

//variables representing the gearbox motors output pins, and the position of the servo.

int motA_1 = 2,motA_2 = 3,motB_1 = 4,motB_2 = 5,pos = 90;

//create a servo object

Servo lrservo;

//create a cur_Dir object to represent the direction of our robot

cur_Dir currentDirection;

//Function Prototypes

void MoveGearBox(RobotDirection);

void MoveServo(RobotDirection);

void setup()

{

//Start the USART so we can receive command from the controller

Serial.begin(4800);

//Set the gearbox motors control pins as outputs

pinMode(motA_1, OUTPUT);

pinMode(motA_2, OUTPUT);

pinMode(motB_1, OUTPUT);

pinMode(motB_2, OUTPUT);

//Attach pin 6 to our servo object

lrservo.attach(6);

//Write the starting position to the servo object which is 90, half of 180

lrservo.write(pos);

//Set the starting direction to nowhere

currentDirection = Nowhere;

}

void loop()

{

//If there are commands available from the controller

while(Serial.available() > 0)

{

//Check if the command character matches any of the following cases

switch(Serial.read())

{

//If it’s ‘F’

case ‘F’:

//Set the current direction of the robot to Forward

currentDirection = Forward;

//Stop checking cases

break;

//If it’s ‘B’

case ‘B’:

//Set the direction to Backwards

currentDirection = Backwards;

//Stop checking cases

break;

//If it’s ‘L’

case ‘L’:

//Set the current direction to Left

currentDirection = Left;

//Stop checking cases

break;

//If it’s ‘R’

case ‘R’:

//Set the current direction to Right

currentDirection = Right;

//Stop checking cases

break;

//This case is evaluated if all other cases fail to match

default:

//in which case we set the current direction to Nowhere

currentDirection = Nowhere;

//and finish checking all the cases

break;

}

//Then we send the current direction to the MoveGearBox function

MoveGearBox(currentDirection);

//And the MoveServo function where it will be evaluated and acted upon accordingly

MoveServo(currentDirection);

}

}

void MoveServo(RobotDirection dir)

{

int servoSpeed = 4;

//If the direction is Left and we have not yet hit the left bound

if(dir == Left && pos > 0)

{

//then decrease the position of the servo (turn counter-clockwise)

pos -= servoSpeed;

}

//But if the direction is Right and we have not reached the right bound

else if(dir == Right && pos < 179)

{

//increase the position of the servo (turn it clockwise)

pos += servoSpeed;

}

//Otherwise, dont change the servos position

else

{

//Don’t Move

pos = pos;

}

//Now that we have an updated position, send it to the servo.

lrservo.write(pos);

}

void MoveGearBox(RobotDirection dir)

{

//If the direction is Forward

if(dir == Forward)

{

//Send a high pulse to motA_1 and motB_1;

//low pulse to motA_2 and motB_2 to make the gearbox move forward

digitalWrite(motA_1, HIGH);

digitalWrite(motA_2, LOW);

delay(15);

digitalWrite(motB_1, HIGH);

digitalWrite(motB_2, LOW);

delay(15);

}

//If the direction is Backwards

else if(dir == Backwards)

{

//Send a high pulse to motA_2 and motB_2;

//low pulse to motA_1 and motB_1 to make the gearbox move backwards

digitalWrite(motA_1, LOW);

digitalWrite(motA_2, HIGH);

delay(15);

digitalWrite(motB_1, LOW);

digitalWrite(motB_2, HIGH);

delay(15);

}

//Otherwise…

else

{

//don’t Move

digitalWrite(motA_1, LOW);

digitalWrite(motA_2, LOW);

digitalWrite(motB_1, LOW);

digitalWrite(motB_2, LOW);

}

}




the error was :
Arduino: 1.6.5 (Windows 8.1), Board: "Arduino Nano, ATmega328"

transmitter_rx_final_1:20: error: variable or field 'MoveServo' declared void
transmitter_rx_final_1:20: error: 'RobotDirection' was not declared in this scope
transmitter_rx_final_1:21: error: variable or field 'MoveGearBox' declared void
transmitter_rx_final_1:21: error: 'RobotDirection' was not declared in this scope
transmitter_rx_final_1:25: error: 'cur_Dir' does not name a type
transmitter_rx_final_1:29: error: variable or field 'MoveGearBox' declared void
transmitter_rx_final_1:29: error: 'RobotDirection' was not declared in this scope
transmitter_rx_final_1:31: error: variable or field 'MoveServo' declared void
transmitter_rx_final_1:31: error: 'RobotDirection' was not declared in this scope
transmitter_rx_final_1.ino: In function 'void setup()':
transmitter_rx_final_1:61: error: 'currentDirection' was not declared in this scope
transmitter_rx_final_1:61: error: 'Nowhere' was not declared in this scope
transmitter_rx_final_1.ino: In function 'void loop()':
transmitter_rx_final_1:87: error: 'currentDirection' was not declared in this scope
transmitter_rx_final_1:87: error: 'Forward' was not declared in this scope
transmitter_rx_final_1:99: error: 'Backwards' was not declared in this scope
transmitter_rx_final_1:111: error: 'Left' was not declared in this scope
transmitter_rx_final_1:123: error: 'Right' was not declared in this scope
transmitter_rx_final_1:135: error: 'Nowhere' was not declared in this scope
transmitter_rx_final_1:145: error: 'currentDirection' was not declared in this scope
transmitter_rx_final_1:145: error: 'MoveGearBox' was not declared in this scope
transmitter_rx_final_1:149: error: 'MoveServo' was not declared in this scope
transmitter_rx_final_1.ino: At global scope:
transmitter_rx_final_1:155: error: variable or field 'MoveServo' declared void
transmitter_rx_final_1:155: error: 'RobotDirection' was not declared in this scope
variable or field 'MoveServo' declared void

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.

so i need an Expert to try the code if he could as shown in the project site that I mentioned above and guide me throw this project.
notes :
1 i'm sorry i'm very beginner .
2 I'm sorry too for my bad English
Thanks a lot

All of the errors are basically saying variables are not defined.
Are you sure your library is actually included?

Add a #pragma message (" Library included") to make sure , it does not look like it.

Who help me ??

Gianluca9779:
Who help me ??

With what? Your issue has nothing to do with the thread you hijacked.

#PaulS thank you too much the code is working now .
Then I need some modifications
I notice that the servo is moving left and right but don't come back to the first position automatically.
How can I do that ?

I notice that the servo is moving left and right but don't come back to the first position automatically.

The servo(s) only move in response to serial input. Why do you expect it/them to return to some prior position?