Arduino coding help

I finally have made my code that has three separate sketches inside to run three different components. This code is for the Arduino uno and sense im not really familiar with coding its really messy, so can someone help clean it up?

Sorry the code is to big to post

REDBIRD_payload_code.ino (15 KB)

Well, this hit me right away...

#include <SD.h>

#include <SD.h>

oh yeah I meant to change that

I'm using a Arduino with three other components and it gives me that error any idea why?
this is just a part of the code due to how large it is

// for Leonardos, if you want to debug SD issues, uncomment this line
  // to see serial output
  //while (!Serial);

  // connect at 115200 so we can read the GPS fast enough and echo without dropping chars
  // also spit it out
  Serial.begin(115200);
  Serial.println("\r\nUltimate GPSlogger Shield");
  pinMode(ledPin, OUTPUT);

  // make sure that the default chip select pin is set to
  // output, even if you don't use it:
  pinMode(10, OUTPUT);

  // see if the card is present and can be initialized:
  //if (!SD.begin(chipSelect, 11, 12, 13)) {
  if (!SD.begin(chipSelect)) {      // if you're using an UNO, you can use this line instead
    Serial.println("Card init. failed!");
    error(2);
  }
  char filename[15];
  strcpy(filename, "GPSLOG00.TXT");
  for (uint8_t i = 0; i < 100; i++) {
    filename[6] = '0' + i / 10;
    filename[7] = '0' + i % 10;
    // create if does not exist, do not open existing, write, sync after write
    if (! SD.exists(filename)) {
      break;
    }
  }

  logfile = SD.open(filename, FILE_WRITE);
  if ( ! logfile ) {
    Serial.print("Couldnt create ");
    Serial.println(filename);
    error(3);
  }
  Serial.print("Writing to ");
  Serial.println(filename);

  // connect to the GPS at the desired rate
  GPS.begin(9600);

  // uncomment this line to turn on RMC (recommended minimum) and GGA (fix data) including altitude
  GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
  // uncomment this line to turn on only the "minimum recommended" data
  //GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCONLY);
  // For logging data, we don't suggest using anything but either RMC only or RMC+GGA
  // to keep the log files at a reasonable size
  // Set the update rate
  GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);   // 100 millihertz (once every 10 seconds), 1Hz or 5Hz update rate

  // Turn off updates on antenna status, if the firmware permits it
  GPS.sendCommand(PGCMD_NOANTENNA);

  // the nice thing about this code is you can have a timer0 interrupt go off
  // every 1 millisecond, and read data from the GPS for you. that makes the
  // loop code a heck of a lot easier!
  useInterrupt(true);

  Serial.println("Ready!");



  // Interrupt is called once a millisecond, looks for any new GPS data, and stores it
     SIGNAL(TIMER0_COMPA_vect) {
    char c = GPS.read();
    // if you want to debug, this is a good time to do it!
#ifdef UDR0
    if (GPSECHO)
      if (c) UDR0 = c;
    // writing direct to UDR0 is much much faster than Serial.print
    // but only one character can be written at a time.
#endif
  }
 
  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;
    }

The error highlights ( SIGNAL(TIMER0_COMPA_vect) { ) on the code

near the bottom of the code

not sure if it will make a difference

  // Interrupt is called once a millisecond, looks for any new GPS data, and stores it
  SIGNAL(TIMER0_COMPA_vect) {
	  char c = GPS.read();
	  // if you want to debug, this is a good time to do it!
	  #ifdef UDR0
	  if (GPSECHO == 1)
	  {
		  if (c == 1)
		  {
			  UDR0 = c;
		  }
	  }
	  
	  // writing direct to UDR0 is much much faster than Serial.print
	  // but only one character can be written at a time.
	  #endif
  }

Hi,
Did you write this code yourself and if you did, did you write it in sections, getting each section working before going to write the next?
Then combine all your sections, one at a time, getting each combination working before going the next?

If your problem is at compilation, and too long to post in code/tags.
You can attach it to your post.

Tom... :slight_smile:

Are you trying to write the ISR inside another function? That won't work.

Or do you have executable code outside of any function? That won't work either.

From your snippet it is impossible to tell.

Please post complete code; as it stands now, your code will indeed not compile starting with the error 'usingInterrupt' was not declared in this scope

can someone help clean it up?

Yes, YOU can. You have NOT told us what the program is supposed to do. You have NOT told us what it actually does.

If I open the file, I'll clean it up. But, then it is extremely unlikely that it will do what you want.

I'm so this code is suppose to run an Adruino Uno, it has a Ultimate GPS data logger shield, and I have a BMP180 altimeter on it, and a Geiger counter. I plan to put my project into a rocket (made from my class) and launch it to collect data.

I get a error code that says
exit status 1
expected unqualified-id before string constant

CPaulP:
I get a error code that says
exit status 1
expected unqualified-id before string constant

It should report the line number as well. Look again.

I think its line 207 it should say SIGNAL(TIMER0_COMPA_vect) {

This was my first time combining a code so I just basically copied and pasted each section but I did check to see if each one worked, here is my code.

REDBIRD_payload_code.ino (15.2 KB)

CPaulP:
This was my first time combining a code so I just basically copied and pasted each section but I did check to see if each one worked, here is my code.

I don't see how that can work. How did you define the inter-operation between parts? Sequentially? At all?

A computer is not like a stewing pot that you can just throw things into.

Also, this is really a duplicate post. Stop doing that.
http://forum.arduino.cc/index.php?topic=480904.msg3283431#msg3283431

Honestly I didn't because I don't know that much of what I'm doing. and when I had the first part of the code it compiled and uploaded but I notices the brackets were wrong so that's when this error came up.
I was following this website the best I can when I put it together.
https://arduino-info.wikispaces.com/CombiningArduinoSketches

@CPaulP, please do not cross-post. Threads merged.

CPaulP:
Honestly I didn't because I don't know that much of what I'm doing. and when I had the first part of the code it compiled and uploaded but I notices the brackets were wrong so that's when this error came up.

Did you follow my suggestion of reading the line number? What was the result?

CPaulP:
I think its line 207 it should say SIGNAL(TIMER0_COMPA_vect) {

There is a missing } before that line.