Arduino programming- combining 2 or more inputs program together

Status
Not open for further replies.

liabilityquek

Newbie level 3
Joined
Nov 14, 2010
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,315
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!
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…