I am trying to combine codes for my 3 sensors: GSR, Pulse sensor, and ECG but I keep getting errors. I have a poor background in coding. I have the 3 codes separately and I'm not the one who wrote them. Here are the new Sketch after Combining the loops and the setups.I didn't get any error after uploading and verifying but I am not getting values in my Serial Monitor
Combined sketch:
<!-- language-all: lang-cpp -->
#include <Wire.h>
#include "rgb_lcd.h"
#define ANALOG_IN 2 // analog input pin to display
#define OUTPUT_PIN 10 // test signal output pin
#define PULSE_MS 250 // pulse width in ms
int PulseSensorPurplePin = 1; // 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.
const int BUZZER=3;
const int GSR=A0;
int threshold=0;
int sensorValue;
rgb_lcd lcd;
long ms; // timer in ms
int out = HIGH; // output level
void setup() {
pinMode(LED13,OUTPUT); // pin that will blink to your heartbeat!
Serial.begin(9600); // Set's up Serial Communication at certain speed.
long sum=0;
//VERIFY VALUE
lcd.begin(16, 2);
Serial.begin(9600);
pinMode(BUZZER,OUTPUT);
digitalWrite(BUZZER,LOW);
delay(1000);
//VERIFY VALUE
for(int i=0;i<500;i++)
{
sensorValue=analogRead(GSR);
sum += sensorValue;
delay(5);
}
threshold = sum/500;
Serial.print("threshold =");
Serial.println(threshold);
pinMode(OUTPUT_PIN, OUTPUT); // set output pin mode
Serial.begin(19200); // initiate serial communication
digitalWrite(OUTPUT_PIN, out); // set initial digital output
ms = millis(); // query current time (in ms)
}
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(100);
int temp;
sensorValue=analogRead(GSR);
Serial.print("sensorValue=");
Serial.println(sensorValue);
lcd.setCursor(0, 0);
lcd.print("GSR Value: ");
lcd.print(sensorValue);
temp = threshold - sensorValue;
if(abs(temp)>50)
{
sensorValue=analogRead(GSR);
temp = threshold - sensorValue;
if(abs(temp)>50){
digitalWrite(BUZZER,HIGH);
Serial.println("YES!");
delay(3000);
digitalWrite(BUZZER,LOW);
delay(1000);}
}
int val = analogRead(ANALOG_IN); // read voltage at input pin
Serial.write( 0xff ); // write value to serial port
Serial.write( (val >> 8) & 0xff );
Serial.write( val & 0xff );
if (millis() >= ms+PULSE_MS) { // check if pulse width has elapsed
ms = millis(); // query current time (in ms)
out = !out; // invert output value
digitalWrite(OUTPUT_PIN, out); // update digital output
}
}
setup()and oneloop()subroutine ... you will have to merge the three subroutines into one for each of those .... first, you need to figure out what the code does