# I am a newbie and I need help to complete my Voltage and Temperature Reader using netduino, thermistor and PV cell

I am doing a small project to read two analog data inputs and display their values on a LCD system. When I did them separately it worked well but I am confused as to how to combine the two codes so that the LCD will display the Temperature on Line 1 while the Voltage on Line 2. The codes I did are as follows. Please add comments when editing my comment since I really need to understand what I am doing as well as what each line of code executes in my program…
The codes are;

using System;
using System.Net;
using System.Net.Sockets;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.NetduinoPlus;
//using LCD;

{
public class Program
{
public static void Main()
{
//Voltagemeter Codes to read and display voltage
Ulcd.Initialise(); //initialise the LCD
vin.SetRange(0, 1023); //Set Ananlog Digital Convertor range to go from 0 to 1023
double digit = 0.0; //This is the AD convertor output value

``````        int fraction = 0;
int wholevalue = 0;
int integervalue = 0;
double volt = 0.0;

while (true)
{
//V=mx+c
volt = (float)(0.06517 * digit * 100);  //Relationship between ADC value and physicall signal being measured
wholevalue = (int)(System.Math.Round(volt));  //remove extra digits want only up to 4 digits
fraction = (wholevalue % 100);  //pull out the fraction part of the value
integervalue = wholevalue / 100;  //pull out the integer part of the value

Ulcd.ShowText(1, "VOLTAGE: = " + integervalue.ToString() + "." + fraction.ToString() + "V");  //send value to LCD for display

Debug.Print("VOLTAGE: = " + integervalue.ToString() + "." + fraction.ToString() + "V");
}

//Thermistor Codes  to read and display temprature
AnalogInput pot = new AnalogInput(Pins.GPIO_PIN_A0);  //connect input to pin #0 of NetDuino
pot.SetRange(0, 1023);  //We want NetDuino values to vary between 0 qnd 1023...there is a 10bits ADC in the NetDuino.
int potvalue = 0;  //store input values as potvalue

while (true)
{
double tempt = 127 * (System.Math.Pow(System.Math.E, -0.002 * potvalue));   //calculate temperature
int myval = (int)tempt;       //convert temperature from double to int
string val = myval.ToString();     //convert temperature from int to string for display
//Debug.Print("NetDuino Value is: " + potvalue);    //display NetDuino value
Debug.Print("Temperature = " + val + "oC");   //display calculated temperature
}
}

}
``````

}

Thanks so much.

It looks like you have the following:

``````Initialisation code for LCD and ADC
while (true)
{
}
Initialise second sensor
while (true)
{
Read second sensor and update display
}
``````

You application will never get to the code below the first `while` loop. You need to modify your application as follows:

``````Initialisation code for LCD and ADC
Initialise second sensor
while (true)
{