user39766: I have been using a temperature sensor and heartbeat sensor separately and I am trying to code for temperature and heartbeat sensors. How do I get its output on the Arduino IDE's Serial Plotter?
Code of temperature sensor:
int val;
int tempPin = 1;

void setup()
{
  Serial.begin(9600);
}
void loop()
{
  val = analogRead(tempPin);
  float mv = ( val / 1024.0) * 5000;
  float cel = mv / 10;
  float farh = (cel * 9) / 5 + 32;

  Serial.print("TEMPRATURE = ");
  Serial.print(cel);
  Serial.print("*C");
  Serial.println();
  delay(1000);

  /* uncomment this to get temperature in farenhite
    Serial.print("TEMPRATURE = ");
    Serial.print(farh);
    Serial.print("*F");
    Serial.println();
  */
}


user10394: If you separate your code into functions you may understand what you want to do better.
In the listing above, you have code that reads the temp and prints the temp.  So creating two functions ReadTemp() and ShowTemp() will make the code in loop look cleaner and easier to read.  i.e.
void loop()
{
    const float cel = ReadTemp();
    DisplayTemp(cel);
    delay(1000);
}

float ReadTemp(void)
{ 
    val = analogRead(tempPin);
    float mv = ( val/1024.0)*5000; 
    float cel = mv/10;
    // float farh = (cel*9)/5 + 32;
    return cel;
}
void ShowTemp(const float& cel)
{
    Serial.print("TEMPRATURE = ");
    Serial.print(cel);
    Serial.print("*C");
    Serial.println();
}

In you sketch for the hearbeat monitor you should have some code that reads the heartbeat and some that prints it.  If you create two functions ReadHB() and ShowHB() you will be able to easily add them to the above loop function.
I've never used the serial plotter, but if you wrap it in a function called PlotTemp() and PlotHB() then you can slot them in instead of the Show functions.

39766: <p>I have been using a temperature sensor and heartbeat sensor separately and I am trying to code for temperature and heartbeat sensors. How do I get its output on the Arduino IDE's Serial Plotter?</p>

<p>Code of temperature sensor:</p>

<pre class="lang-cpp prettyprint-override"><code>int val;
int tempPin = 1;

void setup()
{
  Serial.begin(9600);
}
void loop()
{
  val = analogRead(tempPin);
  float mv = ( val / 1024.0) * 5000;
  float cel = mv / 10;
  float farh = (cel * 9) / 5 + 32;

  Serial.print("TEMPRATURE = ");
  Serial.print(cel);
  Serial.print("*C");
  Serial.println();
  delay(1000);

  /* uncomment this to get temperature in farenhite
    Serial.print("TEMPRATURE = ");
    Serial.print(farh);
    Serial.print("*F");
    Serial.println();
  */
}
</code></pre>
 10394: <p>If you separate your code into functions you may understand what you want to do better.</p>

<p>In the listing above, you have code that reads the temp and prints the temp.  So creating two functions <code>ReadTemp()</code> and <code>ShowTemp()</code> will make the code in loop look cleaner and easier to read.  i.e.</p>

<pre><code>void loop()
{
    const float cel = ReadTemp();
    DisplayTemp(cel);
    delay(1000);
}

float ReadTemp(void)
{ 
    val = analogRead(tempPin);
    float mv = ( val/1024.0)*5000; 
    float cel = mv/10;
    // float farh = (cel*9)/5 + 32;
    return cel;
}
void ShowTemp(const float&amp; cel)
{
    Serial.print("TEMPRATURE = ");
    Serial.print(cel);
    Serial.print("*C");
    Serial.println();
}
</code></pre>

<p>In you sketch for the hearbeat monitor you should have some code that reads the heartbeat and some that prints it.  If you create two functions <code>ReadHB()</code> and <code>ShowHB()</code> you will be able to easily add them to the above loop function.</p>

<p>I've never used the serial plotter, but if you wrap it in a function called <code>PlotTemp()</code> and <code>PlotHB()</code> then you can slot them in instead of the Show functions.</p>
