Kayperkins19:
Need help it keeps saying 'not declared in scope' and I am lost at this point,
Sometimes the first error is not the most important. I fixed a few and there are plenty left. Look at all of the messages and solve the ones you can. Sometimes that will magically fix the first error.
// Robot Demo - Example 2
// Drive in specific pattern using line counting navigation
// SparkFun RedBot Library
#include <RedBot.h>
const int LINETHRESHOLD = 300; // UNDEFINED?!?
// create objects using classes in RedBot library
RedBotButton button;
RedBotMotors motors;
RedBotEncoder encoder(A2, 10);
RedBotSensor leftLine(A3);
RedBotSensor centerLine(A6);
RedBotSensor rightLine(A7);
// global variables for buzzer and LED pin numbers
const int buzzer = 9;
const int led = 13;
// global variables to keep track of which scenario to demonstrate
int scenario = 1;
boolean started = false;
void setup() {
pinMode(buzzer, OUTPUT);
pinMode(led, OUTPUT);
}
void loop() {
checkButton();
if (started == true) {
if (scenario == 1)
scenario1();
else if (scenario == 2)
scenario2();
else if (scenario == 3)
scenario3();
const int followCountLine();
}
}
// CUSTOM FUNCTIONS
void scenario1() {
// Scenario 1: Drive from kitchen to Table 2, drive around table, and return to start
// drive from Start line to Table 2 line
followCountLine(2); // 2nd line will be path to Table 2
pivotAngle(-90); // pivot -90 angle = turn left
followCountLine(1); // next line is the circle around table
pivotAngle(-90);
alertSound(); // food is here!
followCountLine(1); // drive once around table
// turn and return to kitchen
pivotAngle(-90);
followCountLine(1); // next line is main path
pivotAngle(-90);
followCountLine(1); // next line is Start
alertSound(); // robot is ready for next order!
// set global variables for next scenario
scenario = 2;
started = false;
}
void scenario2() {
// add code for Scenario 2
// set global variables for next scenario
scenario = 3;
started = false;
// Scenario 1: Drive from kitchen to Table 2, drive around table, and return to start
// drive from Start line to Table 2 line
followCountLine(2); // 2nd line will be path to Table 2
pivotAngle(-90); // pivot -90 angle = turn left
followCountLine(1); // next line is the circle around table
pivotAngle(-90);
alertSound(); // food is here!
followCountLine(1); // drive once around table
// turn and return to kitchen
pivotAngle(-90);
followCountLine(1); // next line is main path
pivotAngle(-90);
alertSound(); // robot is ready for next order!
// set global variables for next scenario
scenario = 2;
started = false;
}
void scenario3() {
// add code for Scenario 3
// reset global variables for 1st scenario
scenario = 1;
started = false;
}
void checkButton() {
// add code for this custom function
}
void alertSound() {
Serial.print(leftLine.read());
Serial.print("\t"); // tab character
Serial.print(centerLine.read());
Serial.print("\t"); // tab character
Serial.print(rightLine.read());
Serial.println();
if ((leftLine.read() > LINETHRESHOLD) &&
(centerLine.read() > LINETHRESHOLD) &&
(rightLine.read() > LINETHRESHOLD) )
{
motors.brake();
playNote(noteA3, WN);
delay(3000);
motors.leftMotor(leftSpeed);
motors.rightMotor(rightSpeed);
delay(200);
}
else
{
motors.leftMotor(leftSpeed);
motors.rightMotor(rightSpeed);
}
}
void followLine() {
// add code for this custom function
}
void followCountLine(int target) {
// add code for this custom function
}
void driveDistance(float distance, int power) {
// add code for this custom function
}
void pivotAngle(float angle) {
// add code for this custom function
}
Even with those fixed I'm still getting plenty of errors (and warnings, since I have my warning level set to ALL).
/Users/john/Documents/Arduino/sketch_dec10a/sketch_dec10a.ino: In function 'void loop()':
/Users/john/Documents/Arduino/sketch_dec10a/sketch_dec10a.ino:39:31: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
const int followCountLine();
^
/Users/john/Documents/Arduino/sketch_dec10a/sketch_dec10a.ino: In function 'void alertSound()':
sketch_dec10a:120: error: 'noteA3' was not declared in this scope
playNote(noteA3, WN);
^
sketch_dec10a:120: error: 'WN' was not declared in this scope
playNote(noteA3, WN);
^
sketch_dec10a:120: error: 'playNote' was not declared in this scope
playNote(noteA3, WN);
^
sketch_dec10a:122: error: 'leftSpeed' was not declared in this scope
motors.leftMotor(leftSpeed);
^
sketch_dec10a:123: error: 'rightSpeed' was not declared in this scope
motors.rightMotor(rightSpeed);
^
sketch_dec10a:128: error: 'leftSpeed' was not declared in this scope
motors.leftMotor(leftSpeed);
^
sketch_dec10a:129: error: 'rightSpeed' was not declared in this scope
motors.rightMotor(rightSpeed);
^
/Users/john/Documents/Arduino/sketch_dec10a/sketch_dec10a.ino: At global scope:
/Users/john/Documents/Arduino/sketch_dec10a/sketch_dec10a.ino:137:26: warning: unused parameter 'target' [-Wunused-parameter]
void followCountLine(int target) {
^
/Users/john/Documents/Arduino/sketch_dec10a/sketch_dec10a.ino:141:26: warning: unused parameter 'distance' [-Wunused-parameter]
void driveDistance(float distance, int power) {
^
/Users/john/Documents/Arduino/sketch_dec10a/sketch_dec10a.ino:141:40: warning: unused parameter 'power' [-Wunused-parameter]
void driveDistance(float distance, int power) {
^
/Users/john/Documents/Arduino/sketch_dec10a/sketch_dec10a.ino:145:23: warning: unused parameter 'angle' [-Wunused-parameter]
void pivotAngle(float angle) {
^
exit status 1
'noteA3' was not declared in this scope