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