liabilityquek
Newbie level 3
Hi peeps, i needed help in combining two programs into the Arduino Ide. I need these two programs to display the values on the serial monitor. Below will be the two programs i have written up:
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.println (voltage, DEC);
delay (1000);
}
#define SENSOR 0 // select the input pin for
// the LM335A temperature sensor
float val = 0; // variable used to store the value
// coming from the sensor
float val2 = 0;
float deg = 0;
float celcius = 0;
void setup()
{
Serial.begin(9600); // open the serial port to send
// data back to the computer at
// 9600 baud
}
void loop()
{
val = analogRead(SENSOR); // read value from the 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); // print the value to
// the serial port
delay(1000); // wait 1 second between each
}
The first program will show the voltage value, while the second program will show the temperature value. I would like to merge these two programs so that they can display the values on the serial monitor.
Please help asap, i have given a week to solve this, thanks!
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.println (voltage, DEC);
delay (1000);
}
#define SENSOR 0 // select the input pin for
// the LM335A temperature sensor
float val = 0; // variable used to store the value
// coming from the sensor
float val2 = 0;
float deg = 0;
float celcius = 0;
void setup()
{
Serial.begin(9600); // open the serial port to send
// data back to the computer at
// 9600 baud
}
void loop()
{
val = analogRead(SENSOR); // read value from the 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); // print the value to
// the serial port
delay(1000); // wait 1 second between each
}
The first program will show the voltage value, while the second program will show the temperature value. I would like to merge these two programs so that they can display the values on the serial monitor.
Please help asap, i have given a week to solve this, thanks!