Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to merge two arduino program together and display the results on serial monitor?

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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top