void loop()
{
val = analogRead(SENSOR);
val2 = val * 0.00489; // take SENSOR value and multiply it by 4.89mV
// and store value to val2
deg = val2 * 100; // multiply by 100 to get degrees in K
celcius = deg - 273.15; // subtract absolute zero to get degrees celcius
Serial.println(celcius);
delay(1000);
}
This program will print the temperature reading in degree celcius on the serial monitor.
I have tested both programs individually and it worked.
I was wondering if if i can combine both programs together.
However, there is only one serial monitor. So how do i do it?
How should i write my program then?
Can someone please help?
Thank you!! Appreciate much!!
Just put them together.
The setup is the same so just have one.
Put the code in one loop to directly follow the code in the other, there are no variable names in common so you should have no problems, you might want to remove a delay however.
Just put some print statements in front of the print values to identify what the number refers to.
So change:-
voltage = sensorValue * 0.0048; // code width(sensitivity) = 5 / 210 = 4.8mV
Serial.println (voltage, DEC);
to:-
voltage = sensorValue * 0.0048; // code width(sensitivity) = 5 / 210 = 4.8mV
Serial.print("The voltage is ");
Serial.println (voltage, DEC);
void setup( )
{
Serial.begin (9600);
}
void loop( )
{
float voltage = 0;
int sensorValue = analogRead (A0);
voltage = sensorValue * 0.0048; // code width(sensitivity) = 5 / 210 = 4.8mV
Serial.print("The voltage is ");
Serial.println (voltage, DEC);
val = analogRead(SENSOR);
val2 = val * 0.00489; // take SENSOR value and multiply it by 4.89mV
// and store value to val2
deg = val2 * 100; // multiply by 100 to get degrees in K
celcius = deg - 273.15; // subtract absolute zero to get degrees celcius
Serial.print("The temperature reading is ");
Serial.println(celcius);
}
Why do u not need the delay anymore?
How will the serial monitor looked like?
That was done at someone else computer which seems to have some cut/copy/paste buffer bug, or key failure, as the e-mail to myself has the pin assignment correct.
As to the DEC in the print statement, as I said the code is a rearrangement of that in the first posting above in which you'll find the same problem.
EDIT:
Oh, and AWOL thanks for noticing that and bringing it to my attention.