i'm displaying the temperature on 16x2 LCD using atmega16 microcontroller , in the super loop i'm calling the function to display the temperature on the screen , in case the temperature is 136C ( for example ) and temperature becomes 50C , the screen displayed 50CC , i want it to be 50C , how to modify the function to handle this ?
#include "lcd.h"
#include "adc.h"
#include "stdio.h"
#include "stdlib.h"
uint8 g_flag = 0 ;
uint16 g_adc_value = 0 ;
float32 g_voltage = 0 ;
float32 g_temprature = 0 ;
float32 g_resolution = 0.0048828 ;
void display_temprature(sint16 a_temprature) ;
int main(void)
{
LCD_init() ;
ADC_init() ;
LCD_displayStringRowCol(0 , 1 , "Temprature is") ;
while(1)
{
g_adc_value = ADC_readChannel(1) ;
g_voltage = g_adc_value*g_resolution ;
g_temprature = g_voltage / 0.01 ;
display_temprature((sint16)g_temprature) ;
}
}
void display_temprature(sint16 a_temprature)
{
LCD_goToRowCol(1 , 7) ;
LCD_integerToString(a_temprature) ;
LCD_displayCharacter(223) ;
LCD_displayCharacter('C') ;
}