COMBINE TWO CODES

gps code
#include <math.h>
#include <nmea.h>
#include <LiquidCrystal.h>
#include <NewSoftSerial.h>
NewSoftSerial mygps(7, 8);

NMEA myGPS(GPRMC);
LiquidCrystal myLCD = LiquidCrystal(12, 11, 5, 4, 3, 2);

float dest_latitude = 25.36763;
float dest_longitude = 68.35304;
void setup() {
myLCD.begin(16,2);
mygps.begin(4800);
pinMode(13, OUTPUT); // diagnostic led on Wiring-board

myLCD.clear();
myLCD.home();
myLCD.print(“Boby”);
delay(3000);
void loop() {

if (mygps.available() > 0 ) {

if (myGPS.decode(mygps.read())) {

myLCD.clear();
myLCD.home();
float lat; float lon;
lat=myGPS.gprmc_latitude();
lon = myGPS.gprmc_longitude();
myLCD.setCursor(0,0);
myLCD.print(“D:”);
float d=(round(myGPS.gprmc_distance_to(dest_latitude, dest_longitude, MTR)));
myLCD.print(d);
myLCD.print(“m”);
if (d < 20){digitalWrite(13, HIGH);}
if (d > 20){digitalWrite(13, LOW);}

float mydir = calc_bearing (lat, lon, dest_latitude, dest_longitude);

if (mydir < 0) { mydir += 360; }
if (mydir > 180) { mydir -= 360; }

// display relative direction to destination
myLCD.setCursor(0,1);
if (mydir < 0) {
myLCD.print(’<’); // destination is to your left
} else {
myLCD.print(’>’); // destination is to your right
}
myLCD.print(abs(mydir), DEC);
myLCD.print(223, BYTE); // print °-character

}
}
}

int calc_bearing(float flat1, float flon1, float flat2, float flon2)
{
float calc;
float bear_calc;

float x = 69.1 * (flat2 - flat1);
float y = 69.1 * (flon2 - flon1) * cos(flat1/57.3);

calc=atan2(y,x);

bear_calc= degrees(calc);

if(bear_calc<=1){
bear_calc=360+bear_calc;
}
return bear_calc;
}
AND CAR STEERING CODE, THAT IS WRITTEN IN NEW FILE

const int potPin = A0;
const int leftMotor = 10; //PWM pin to the L293
const int rightMotor = 9; //PWM pin to the L293
int motorA1=11;
int motorA2=12;
char Dir;
void setup() {

}
void loop()
{
for(int i=0;i<100;i++)
{
motorForward();
}
steering(‘L’);
for(int i=0;i<100;i++)
{
motorBackward();
}
steering(‘C’);
for(int i=0;i<70;i++)
{
motorForward();
}
steering(‘R’);
delay(3000);
steering(‘C’)
}

ABOVE CODE LINE IS NewSoftSerial mygps(7,8) ;

TEL ME GUYS, IF I HAVE DIFFERNET CODE AND EACH CODE HAVING VOID LOOP(INSIDE OTHER PROGRAMING LOOP ACCORDING TO THE CONDITION WHAT I WANT TO DO), THEN “THERE ARE SOME STEPS WHICH I SHOULD DO, JUST AS
FIRST ALL HEADER FILES ARE WRITTEN
THEN DECLARE VARIBLES, PINS ETC
THEN NEWSOFTSERIAL // IF NEEDED
THEN voidsetup()
THEN void loop() { AFTER THIS ,WRITTEN ALL VOID LOOP OF DIFFEREND CODE JUST AS
sensoring( )
steering( ) } THEN CLOS voidloop braces,
THEN OPEN " NEW TAB”
AND WRITTEN CODE LOOP AS void sensing() { //code//…}

Shhhhh!

Why is this a pole?

I voted for PROGRAMING

Please use CODE TAGS when posting code.

Poll!!! I voted 'COMBINE TWO CODES'. I'm sure I got it right this time.

@OP: Turn Caps Lock off.

You don't need a second tab. You can define your new sensoring() function in the same tab as the rest of the sketch.

GUYS HELP, WHAT IS WRONG IN DIS CODE, THESE CODE I M WRITTEN IN NEW TAB FORM

CAR.pde (258 Bytes)

GPS_nevig.pde (1.34 KB)

GUYZ, I MAUSING CAPSLOCK, TO REPESENT THAT, IT IS NOT PROGRAMING, IT IS STATMENT WHICH I WANT TO ASK U

Please, stop shouting and start making sense.

I MAUSING CAPSLOCK...

Please don't. It's not necessary. We can tell the difference between code and question.

And Please don't PM members, unless they ask you to.

I MAUSING CAPSLOCK, TO REPESENT THAT, IT IS NOT PROGRAMING, IT IS STATMENT WHICH I WANT TO ASK U

So don't. Take off the caps lock and stop talking like a retard.

 gps code
#include <math.h>
#include <nmea.h>
#include <LiquidCrystal.h>
#include <NewSoftSerial.h>
NewSoftSerial mygps(7, smiley-cool;

NMEA myGPS(GPRMC);
LiquidCrystal myLCD = LiquidCrystal(12, 11, 5, 4, 3, 2);

float dest_latitude = 25.36763;
float dest_longitude = 68.35304;  
void setup() {
myLCD.begin(16,2);
  mygps.begin(4800);
  pinMode(13, OUTPUT);  // diagnostic led on Wiring-board
 
  myLCD.clear();
  myLCD.home();
 myLCD.print("Boby");
  delay(3000);
  void loop() {

  if (mygps.available() > 0 ) {

 if (myGPS.decode(mygps.read())) {
        
 myLCD.clear();
  myLCD.home();
      float lat; float lon;
      lat=myGPS.gprmc_latitude();
      lon = myGPS.gprmc_longitude();
      myLCD.setCursor(0,0);
      myLCD.print("D:");
     float d=(round(myGPS.gprmc_distance_to(dest_latitude, dest_longitude, MTR)));
     myLCD.print(d);
      myLCD.print("m");
      if (d < 20){digitalWrite(13, HIGH);}
      if (d > 20){digitalWrite(13, LOW);}
      
    
      
      float mydir = calc_bearing (lat, lon, dest_latitude, dest_longitude);
      
       if (mydir < 0) { mydir += 360; }
      if (mydir > 180) { mydir -= 360; }
      
      // display relative direction to destination
      myLCD.setCursor(0,1);
      if (mydir < 0) {
        myLCD.print('<');  // destination is to your left
      } else {
        myLCD.print('>');  // destination is to your right
      }
      myLCD.print(abs(mydir), DEC);
      myLCD.print(223, BYTE);  // print °-character
        }
  }
}



int calc_bearing(float flat1, float flon1, float flat2, float flon2)
{
  float calc;
  float bear_calc;

  float x = 69.1 * (flat2 - flat1);
  float y = 69.1 * (flon2 - flon1) * cos(flat1/57.3);

  calc=atan2(y,x);

  bear_calc= degrees(calc);

  if(bear_calc<=1){
    bear_calc=360+bear_calc;
  }
  return bear_calc;
}  
 
AND CAR STEERING CODE, THAT IS WRITTEN IN NEW FILE


const int potPin = A0;
const int leftMotor = 10; //PWM pin to the L293
const int rightMotor = 9; //PWM pin to the L293
int     motorA1=11;
int     motorA2=12;
char Dir;
void setup() {
  
}
void loop()
{
  for(int i=0;i<100;i++)
  {
    motorForward();
  }
  steering('L');
  for(int i=0;i<100;i++)
  {
    motorBackward();
  }
  steering('C');
  for(int i=0;i<70;i++)
  {
  motorForward();
  }
  steering('R');
  delay(3000);
  steering('C')
}

sorry guyz, mistyping, becuz i hav too much stress , for comine them

You can only have one function called loop and one called setup.
So first off rename these two loop1() setup1() and loop2() and setup2()
Then write a new function:_

void setup(){
setup1();
setup2();
}

void loop(){
loop1();
loop2();
}

The the code should compile.

then loop1 body is writen in new tab?????

No it can all be in the same file / tab

but i want in new tab because, i have also etthernet shield code for reading udp packets, and different code in different file, but when i open any file, should be open all files that is related to it,

So put it in a new tab. Save a blank file with a .ino in the same folder as the main sketch with your finder, then restart the arduino and the new tab will appear in the sketch.