Combine 4 code together

Hi! I’m new to using an Arduino and I have a problem to combine four code to gather, which I use pulse, temperature and gps sensor.

I’m using an Arduion uno and GSM Shield where my project is about sending data from the arduino to the mobile, and when I combine the code it shows error.

Can any one help me to combine the four code.

For GSM Sensor:

/*
SMS sender

This sketch, for the Arduino GSM shield,sends an SMS message
you enter in the serial monitor. Connect your Arduino with the
GSM shield and SIM card, open the serial monitor, and wait for
the “READY” message to appear in the monitor. Next, type a
message to send and press “return”. Make sure the serial
monitor is set to send a newline when you press return.

Circuit:

  • GSM shield
  • SIM card that can send SMS

created 25 Feb 2012
by Tom Igoe

This example is in the public domain.

*/

// Include the GSM library
#include <GSM.h>

#define PINNUMBER “”

// initialize the library instance
GSM gsmAccess;
GSM_SMS sms;

void setup() {
// initialize serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}

Serial.println(“SMS Messages Sender”);

// connection state
boolean notConnected = true;

// Start GSM shield
// If your SIM has PIN, pass it as a parameter of begin() in quotes
while (notConnected) {
if (gsmAccess.begin(PINNUMBER) == GSM_READY) {
notConnected = false;
} else {
Serial.println(“Not connected”);
delay(1000);
}
}

Serial.println(“GSM initialized”);
}

void loop() {

Serial.print("Enter a mobile number: ");
char remoteNum[20]; // telephone number to send sms
readSerial(remoteNum);
Serial.println(remoteNum);

// sms text
Serial.print("Now, enter SMS content: ");
char txtMsg[200];
readSerial(txtMsg);
Serial.println(“SENDING”);
Serial.println();
Serial.println(“Message:”);
Serial.println(txtMsg);

// send the message
sms.beginSMS(remoteNum);
sms.print(txtMsg);
sms.endSMS();
Serial.println("\nCOMPLETE!\n");
}

/*
Read input serial
*/
int readSerial(char result) {
int i = 0;
while (1) {
while (Serial.available() > 0) {
char inChar = Serial.read();
if (inChar == ‘\n’) {
result = ‘\0’;

  • Serial.flush();*
  • return 0;*
  • }*
  • if (inChar != ‘\r’) {*
    _ result = inChar;_
    * i++;*
    * }*
    * }*
    * }*
    }
    For temperature sensor:
    /********************************************************************/
    // First we include the libraries
    #include <OneWire.h>
    #include <DallasTemperature.h>
    /********************************************************************/
    // Data wire is plugged into pin 2 on the Arduino
    #define ONE_WIRE_BUS 2
    /********************************************************************/
    *// Setup a oneWire instance to communicate with any OneWire devices *
    // (not just Maxim/Dallas temperature ICs)
    OneWire oneWire(ONE_WIRE_BUS);
    /********************************************************************/
    // Pass our oneWire reference to Dallas Temperature.
    DallasTemperature sensors(&oneWire);
    /********************************************************************/
    void setup(void)
    {
    // start serial port
    Serial.begin(9600);
    Serial.println(“Dallas Temperature IC Control Library Demo”);
    // Start up the library
    sensors.begin();
    }
    void loop(void)
    {
    // call sensors.requestTemperatures() to issue a global temperature
    // request to all devices on the bus
    /********************************************************************/
    Serial.print(" Requesting temperatures…");
    sensors.requestTemperatures(); // Send the command to get temperature readings
    Serial.println(“DONE”);
    /********************************************************************/
    Serial.print("Temperature is: ");
    *Serial.print(sensors.getTempCByIndex(0)); // Why “byIndex”? *
    * // You can have more than one DS18B20 on the same bus. *
    * // 0 refers to the first IC on the wire*
    * delay(1000);*
    }
    For pulse sensor
    /* PulseSensor™ Starter Project and Signal Tester
    * The Best Way to Get Started With, or See the Raw Signal of, your PulseSensor™ & Arduino.
    *
    * Here is a link to the tutorial
    * The "GettingStartedProject" – World Famous Electronics llc.
    *
    * WATCH ME (Tutorial Video):
    * - YouTube
    *
    *
    -------------------------------------------------------------
    1) This shows a live human Heartbeat Pulse.
    2) Live visualization in Arduino’s Cool “Serial Plotter”.
    3) Blink an LED on each Heartbeat.
    4) This is the direct Pulse Sensor’s Signal.
    5) A great first-step in troubleshooting your circuit and connections.
    6) “Human-readable” code that is newbie friendly."
    */
    // Variables
    int PulseSensorPurplePin = 0; // Pulse Sensor PURPLE WIRE connected to ANALOG PIN 0
    int LED13 = 13; // The on-board Arduion LED
    int Signal; // holds the incoming raw data. Signal value can range from 0-1024
    int Threshold = 550; // Determine which Signal to “count as a beat”, and which to ingore.
    // The SetUp Function:
    void setup() {
    * pinMode(LED13,OUTPUT); // pin that will blink to your heartbeat!*
    * Serial.begin(9600); // Set’s up Serial Communication at certain speed.*
    }
    // The Main Loop Function
    void loop() {
    * Signal = analogRead(PulseSensorPurplePin); // Read the PulseSensor’s value.*
    * // Assign this value to the “Signal” variable.*
    * Serial.println(Signal); // Send the Signal value to Serial Plotter.*
    * if(Signal > Threshold){ // If the signal is above “550”, then “turn-on” Arduino’s on-Board LED.*
    * digitalWrite(LED13,HIGH);*
    * } else {*
    * digitalWrite(LED13,LOW); // Else, the sigal must be below “550”, so “turn-off” this LED.*
    * }*
    delay(1000);
    }
    For GPS Sensor
    #include <LiquidCrystal.h>
    #include <SoftwareSerial.h>
    #include <TinyGPS.h>
    float lat = 28.5458,lon = 77.1703; // create variable for latitude and longitude object
    SoftwareSerial gpsSerial(3,4);//rx,tx
    LiquidCrystal lcd(A0,A1,A2,A3,A4,A5);
    TinyGPS gps; // create gps object
    void setup(){
    Serial.begin(9600); // connect serial
    //Serial.println(“The GPS Received Signal:”);
    gpsSerial.begin(9600); // connect gps sensor
    lcd.begin(16,2);
    }

void loop(){
* while(gpsSerial.available()){ // check for gps data*
* if(gps.encode(gpsSerial.read()))// encode gps data*
* {*
* gps.f_get_position(&lat,&lon); // get latitude and longitude*
* // display position*
* lcd.clear();*
* lcd.setCursor(1,0);*
* lcd.print(“GPS Signal”);*
* //Serial.print("Position: ");*
* //Serial.print(“Latitude:”);*
* //Serial.print(lat,6);*
* //Serial.print(";");*
* //Serial.print(“Longitude:”);*
* //Serial.println(lon,6);*
* lcd.setCursor(1,0);*
* lcd.print(“LAT:”);*
* lcd.setCursor(5,0);*
* lcd.print(lat);*
* //Serial.print(lat);*
* //Serial.print(" ");*

* lcd.setCursor(0,1);*
* lcd.print(",LON:");*
* lcd.setCursor(5,1);*
* lcd.print(lon);*

* }*
* }*

* String latitude = String(lat,6);*
* String longitude = String(lon,6);*
* Serial.println(latitude+";"+longitude);*
* delay(1000);*

}
Any help would be greatly appreciated! Thank you!

Any help would be greatly appreciated!

You can't create a program, even with lots of bits to pick and choose from, until you have some requirements. If you do have some, you forgot to tell us what they are.

Hi, I want to make the arduino send a message with the data that it shows the heartbeats, Temperature of the body and the location, where I connect all the sensor but it doesn’t work.

but it doesn't work.

What doesn't? What does it, whatever it is, actually do? How does that differ from what you want?