I don't know the "best" way, but I would use SENSOR_1. You also need to declare the variable. I assume you want a 16-bit signed value, so you should also add "int temp;". I would also not display the number 1 pixel from bottom and left. I would use LCD_LINE1, 0. You also need to clear the screen from previous values. I would use ClearScreen(), and to slow it down so it doesn't flicker a lot I would add a 50ms wait. I would make the program like this:
Code: Select all
int temp;
task main()
{
SetSensor(S1, SENSOR_CELSIUS);
while(true)
{
temp = SENSOR_1;
ClearScreen();
NumOut(LCD_LINE1, 0, temp);
Wait(50);
}
}
And if you only want to display the temperature, you don't even need variable temp.
Here is how I would do it simply:
Code: Select all
task main()
{
SetSensor(S1, SENSOR_CELSIUS);
while(true)
{
ClearScreen();
NumOut(LCD_LINE1, 0, SENSOR_1);
Wait(50);
}
}
Or with a more fancy appearance:
Code: Select all
task main()
{
SetSensor(S1, SENSOR_CELSIUS);
while(true)
{
string temp = NumToStr(SENSOR_1) + " C";
ClearScreen();
TextOut(LCD_LINE1, 0, temp);
Wait(50);
}
}
Note however, that I didn't test run any of these programs.