...was not declared in this scope

I combined a couple projects into one so Im getting some errors and the one I'm on now has a bunch of things show up as not declared. I believe they are part of the SoftwareSerial.h library which is included. Here is the error...Any suggestions??
Arduino: 1.6.9 (Mac OS X), Board: "Arduino/Genuino Uno"

/Users/jordan/Downloads/Autonomous_Car/Autonomous_Car.ino: In function 'void loop()':
Autonomous_Car:239: error: 'processGPS' was not declared in this scope
processGPS();
^
Autonomous_Car:244: error: 'checkSonar' was not declared in this scope
checkSonar();
^
Autonomous_Car:245: error: 'moveAndAvoid' was not declared in this scope
moveAndAvoid();
^
/Users/jordanrose/Downloads/Autonomous_Car/Autonomous_Car.ino: In function 'void print_range()':
Autonomous_Car:256: error: a function-definition is not allowed here before '{' token
{
^
Autonomous_Car:275: error: a function-definition is not allowed here before '{' token
{
^
Autonomous_Car:285: error: a function-definition is not allowed here before '{' token
void read_sensor (){
^
Autonomous_Car:293: error: a function-definition is not allowed here before '{' token
{read_sensor();
^
Autonomous_Car:452: error: expected '}' at end of input
}
^
exit status 1
'processGPS' was not declared in this scope

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

So..... you have bugs in your code, and you want people here to guess what's wrong, without being able to see the code?

I'll pass...

Regards,
Ray L.

Chill bud I didn't know that wasn't enough for u. I'm new. Next time I'll try and learn everything in the world about something before asking a question. BTW the code doesn't fit or I would've added it. Ill add what I can...

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_LSM303_U.h>
#include <Servo.h>
#include <waypointClass.h>                        // custom class to manaage GPS waypoints
#include <Adafruit_GPS.h>                          // GPS
#include <SoftwareSerial.h>                       // used by: GPS
#include <math.h>                                 // used by: GPS

/* Assign a unique ID to this sensor at the same time */
Adafruit_LSM303_Mag_Unified mag = Adafruit_LSM303_Mag_Unified(12345);

//Sonar
 const int pwPin1 = 3;
long sonar, mm;
int triggerCount;

Servo Steering;
Servo motor;

// Pi for calculations - not the raspberry type
const float Pi = 3.14159;

// This is the value that gives you minimal rotation on
// a continuous rotation servo.  It is usually about 90.
// adjust this value to give minimal rotation for your servo
const float SteeringNeutral = 100;  
 
// This is the desired direction of travel
// expressed as a 0-360 degree compass heading
// 0.0 = North
// 90.0 = East
// 180.0 = South
// 270 = West
//const float targetHeading = 0.0; //Take a look at this********
 

// Compass navigation
int targetHeading;              // where we want to go to reach current waypoint
int currentHeading;             // where we are actually facing now
int headingError;               // signed (+/-) difference between targetHeading and currentHeading
#define HEADING_TOLERANCE 5     // tolerance +/- (in degrees) within which we don't attempt to turn to intercept targetHeading


// GPS Navigation
#define GPSECHO false           // set to TRUE for GPS debugging if needed
//#define GPSECHO true           // set to TRUE for GPS debugging if needed
SoftwareSerial mySerial(8, 7);    // digital pins 7 & 8
Adafruit_GPS GPS(&mySerial);
boolean usingInterrupt = false;
float currentLat,
      currentLong,
      targetLat,
      targetLong;
int distanceToTarget,            // current distance to target (current waypoint)
    originalDistanceToTarget;    // distance to original waypoing when we started navigating to it


// Waypoints
#define WAYPOINT_DIST_TOLERANE  3   // tolerance in meters to waypoint; once within this tolerance, will advance to the next waypoint
#define NUMBER_WAYPOINTS 5          // enter the numebr of way points here (will run from 0 to (n-1))
int waypointNumber = -1;            // current waypoint number; will run from 0 to (NUMBER_WAYPOINTS -1); start at -1 and gets initialized during setup()
waypointClass waypointList[NUMBER_WAYPOINTS] = {waypointClass(40.142823, -83.060445), waypointClass(40.142524, -83.060413), waypointClass(40.142239, -83.061294), waypointClass(40.142522, -83.060407), waypointClass(40.142813,-83.060444) };



// Speeds (range: 1150 - 2000)
#define FAST_SPEED 1800
#define NORMAL_SPEED 1400
#define TURN_SPEED 1200
#define SLOW_SPEED 1150
int speed = NORMAL_SPEED;


// Interrupt is called once a millisecond, looks for any new GPS data, and stores it
SIGNAL(TIMER0_COMPA_vect) 
{
  GPS.read();
}


//
// turn interrupt on and off
void useInterrupt(boolean v) 
{
  if (v) {
    // Timer0 is already used for millis() - we'll just interrupt somewhere
    // in the middle and call the "Compare A" function above
    OCR0A = 0xAF;
    TIMSK0 |= _BV(OCIE0A);
    usingInterrupt = true;
  } else {
    // do not call the interrupt function COMPA anymore
    TIMSK0 &= ~_BV(OCIE0A);
    usingInterrupt = false;
  }
}

void setup() 
{
Serial.begin(9600);
  Serial.println("Magnetometer Test"); Serial.println("");
  
  /* Initialise the sensor */
  if(!mag.begin())
  {
    /* There was a problem detecting the LSM303 ... check your connections */
    Serial.println("Ooops, no LSM303 detected ... Check your wiring!");
    while(1);
  }
  
  Steering.attach(10); //Attach Steering to pin 10
  motor.attach(9); //Attach motor to pin 9
  
  // turn on serial monitor 
  Serial.begin(115200);        // we need this speed for the GPS



  //
  // Start motor drives
  //AFMS.begin();  // create with the default frequency 1.6KHz
  
  // Set the speed to start, from 0 (off) to 255 (max speed)
  motor.writeMicroseconds(NORMAL_SPEED);      
  
  

  //
  // start GPS and set desired configuration
  GPS.begin(9600);                                // 9600 NMEA default speed
  GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);     // turns on RMC and GGA (fix data)
  GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);       // 1 Hz update rate
  GPS.sendCommand(PGCMD_NOANTENNA);                // turn off antenna status info
  useInterrupt(true);                            // use interrupt to constantly pull data from GPS
  delay(1000);
      
  //
  // Wait for GPS to get signal
  #ifndef NO_GPS_WAIT
    unsigned long startTime = millis();
  while (!GPS.fix)                      // wait for fix, updating display with each new NMEA sentence received
    {
             GPS.parse(GPS.lastNMEA());      
    } // while (!GPS.fix)
  //delay(1000);
#endif
  

       if (GPS.newNMEAreceived())
           GPS.parse(GPS.lastNMEA());      
      delay(500);

  // get initial waypoint; also sets the distanceToTarget and courseToTarget varilables
// nextWaypoint();
  


 Serial.begin(9600);
  pinMode(pwPin1, INPUT);
 

   triggerCount = 0;

  
     


  
} // setup()

 


void loop()
{

  /* Get a new sensor event */ 
  sensors_event_t event; 
  mag.getEvent(&event);
     
  // Calculate the angle of the vector y,x
  float heading = (atan2(event.magnetic.y,event.magnetic.x) * 180) / Pi;
  // Normalize to 0-360
 
  /* Once you have your heading, you must then add your 'Declination Angle', 
  which is the 'Error' of the magnetic field in your location.  
  Find yours here: http://www.magnetic-declination.com/ 
  Powell, OH: Magnetic declination: 7° 2' West (Negative); 1 degreee = 0.0174532925 radians */
  #define DEC_ANGLE 7 
  heading -= DEC_ANGLE;
  
  if (heading < 0)
  {
    heading = 360 + heading;
  }
  
  // Calculate the error between tha measured heading and the target heading.
  float error = heading - targetHeading;
  if (error > 180)
  {
    error = error - 360;  // for angles > 180, correct in the opposite direction.
  }
  // A non-zero difference between the heading and the 
  // targetHeading will bias the servoNeutral value and 
  // cause the servo to rotate back toward the targetHeading.
  // The divisor is to reduce the reaction speed and avoid oscillations
  Steering.write(SteeringNeutral + error / 4 );
 
  delay(40);
  
       
    // Process GPS 
    if (GPS.newNMEAreceived())               // check for updated GPS information
      {                                      
        if(GPS.parse(GPS.lastNMEA()) )      // if we successfully parse it, update our data fields
          processGPS();   
      } 
  
  
    // distance in front of us, move, and avoid obstacles as necessary
    checkSonar();
    moveAndAvoid();  
   
}  // loop()

   void print_range(){
  Serial.println(mm);
 


// Called after new GPS data is received; updates our position and course/distance to waypoint
void processGPS(void)
{
  currentLat = convertDegMinToDecDeg(GPS.latitude);
  currentLong = convertDegMinToDecDeg(GPS.longitude);
             
  if (GPS.lat == 'S')            // make them signed
    currentLat = -currentLat;
  if (GPS.lon = 'W')  
    currentLong = -currentLong; 
             
  // update the course and distance to waypoint based on our new position
  distanceToWaypoint();
  courseToWaypoint();         
  
}   // processGPS(void)




void checkSonar(void)
{   
  int dist;
  if (dist == 0)                                // if too far to measure, return max distance;
    dist = 2000;  

} // checkSonar()




void read_sensor (){
  sonar = pulseIn(pwPin1, HIGH);
  mm = sonar;
  
}


void moveAndAvoid(void)
{read_sensor();
  print_range();
  delay(100);

 



Cut due to character limit...

Jordanar:
Chill bud I didn't know that wasn't enough for u. I'm new. Next time I'll try and learn everything in the world about something before asking a question. BTW the code doesn't fit or I would've added it. Ill add what I can...

Did you consider attaching your code?
That's clearly stated in "How to use this forum", item #8, here:- http://forum.arduino.cc/index.php/topic,148850.0.html

BTW, that attitude won't get you far here.
How could you possibly have hoped for anyone to help with your code when you didn't show it?

And if you remove all of the unnecessary blank lines before posting you could fit a lot more in a post.

Also, it's a good idea to hit Ctrl-T to format your code properly before posting.

Overall, if you want people to give up their time to help you, make it as easy as possible for them to do so.

I appreciate the advice thanks. Idk why that guy came in and dropped a comment like I was some idiot for not knowing that. Like not everybody has spent their whole life doing this how would I know the error message wasn't enough for help. And I do very much appreciate the help.

Jordanar:
I appreciate the advice thanks. Idk why that guy came in and dropped a comment like I was some idiot for not knowing that. Like not everybody has spent their whole life doing this how would I know the error message wasn't enough for help. And I do very much appreciate the help.

It looks like misplaced brackets will be a large part of the problem. We can't help with that unless we can see the full code.

If you attach the full code someone can probably help sort out your errors. (Click "Reply" instead of using the "Quick Reply" text box, then the "Attachments and other options" link will be visible. :wink: )

Edit: I see you've already deleted your last post. And the one with part of your code? All very confusing. They've both re-appeared. Thanks AWOL :slight_smile:

Jordanar:
I appreciate the advice thanks. Idk why that guy came in and dropped a comment like I was some idiot for not knowing that. Like not everybody has spent their whole life doing this how would I know the error message wasn't enough for help. And I do very much appreciate the help.

I think it's because us old "dudes" expect you new "dudes" to read what's at the top of the Forum, especially the two titled:

How to use this forum - please read.
Read this before posting a programming question ...

Oh, and Steve's right, being a smart-ass won't get you the help you need. Some readers here have over 60,000 posts and are probably some of the most talented problem solvers you'll find anywhere. It's in your interest to court their favor, not piss them off. For a while, at least, hat-in-hand and appreciation for all that they can bring to the table for you is probably a good tact for you at this point.

// Interrupt is called once a millisecond, looks for any new GPS data, and stores it
SIGNAL(TIMER0_COMPA_vect)
{
  GPS.read();
}

The comment is bullshit. The code reads a character from the GPS, regardless of whether or not there is anything to read AND discards it. It does NOT store it.

        if(GPS.parse(GPS.lastNMEA()) )      // if we successfully parse it, update our data fields
          processGPS();

So, where IS processGPS() defined?

   void print_range(){
  Serial.println(mm);
 


// Called after new GPS data is received; updates our position and course/distance to waypoint
void processGPS(void)
{

Ah, here, in the middle of the print_range() function. YOU CAN NOT DO THAT!

I really can not believe that you are trying to develop a library when you can't even understand BASIC concepts, like where a function starts and ends, or even something as
simple as proper
indenting.

That last bit is absolutely inexcusable, given that there is a function, on the Tools menu, called Auto Format which will fix your pathetic indenting since you are too lazy to do it yourself.

please help Arduino: 1.8.1 (Windows 7), Board: "Arduino/Genuino Uno"

C:\Users\admin\Documents\Arduino\project_10\project_10.ino: In function 'void setup()':

project_10:18: error: 'enablePin' was not declared in this scope

pinMode(enablePin, OUTPUT)

^

C:\Users\admin\Documents\Arduino\project_10\project_10.ino: In function 'void loop()':

project_10:23: error: too many arguments to function 'int digitalRead(uint8_t)'

digitalRead(onOffSwitchStateSwitchPin, INPUT);

^

In file included from sketch\project_10.ino.cpp:1:0:

C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:135:5: note: declared here

int digitalRead(uint8_t);

^

project_10:28: error: 'onOffSwitchState' was not declared in this scope

if (onOffSwitchState != previousDirectionSwitchState){

^

project_10:42: error: 'enablePin' was not declared in this scope

analogWrite(enablePin, motorSpeed);

^

project_10:45: error: 'enablePin' was not declared in this scope

analogWrite(enablePin, 0);

^

exit status 1
'enablePin' was not declared in this scope

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

Help is impossible without seeing your code.

756E6C:
Help is impossible without seeing your code.

Not quite :wink:

@OP
Declare the pins and states. Remember that /C++ is case sensitive.
Read up what digitalRead requires and also look at digitalWrite.

digitalRead(onOffSwitchStateSwitchPin, INPUT);You might like to check the syntax of the digitalRead() function too.

UKHeliBob:
digitalRead(onOffSwitchStateSwitchPin, INPUT);You might like to check the syntax of the digitalRead() function too.

Gee, you mean that digitalRead() and pinMode() are not aliases for the same function? I'm shocked!

/*

*/

void setup() {

int Red = 2;

int Yello = 3;

int Green = 4;

}

void loop() {

digitalWrite(Red, HIGH);
delay(5000);
digitalWrite(Red, LOW);
digitalWrite(Yello, HIGH);
delay(1500);
digitalWrite(Yello, LOW);
digitalWrite(Green, HIGH);
digitalWrite(Green, LOW);
delay(5000);

}

You are declaring 3 variables in setup() so they will only be available in that function.

Move the declarations outside of any function to make them available globally throughout the program. You also need to set the pinMode() of the pins to OUTPUT