PIC16F877-HIH-5030-TMP36-Main

by Marwen Maghrebi
void main(void) {
    // Configure LCD control and data pins as output
    TRISC &= ~(1 << 0 | 1 << 1 | 1 << 2);
    TRISD &= ~(1 << 4 | 1 << 5 | 1 << 6 | 1 << 7);
    
    lcd_initialize(); // Initialize the LCD
    configure_ADC();  // Configure ADC module
    
    while (1) {
        // Get the temperature reading from TMP36
        double temperature_value = readTemperature();
        
        // Format temperature value for display
        char temperature_str[16];
        sprintf(temperature_str,"Temp : %.2f C", temperature_value);
        
        // Get the humidity reading (averaged from multiple readings)
        double humidity_value = readHumidity();
        
        // Format humidity value for display
        char humidity_str[16];
        sprintf(humidity_str, "Hum  : %.2f %%", humidity_value);
        
        // Display temperature on the 1st row
        lcd_command(0x80); // Position cursor at 1st Row, 1st Column
        lcd_string((const unsigned char *)temperature_str, strlen(temperature_str));
        
        // Display humidity on the 2nd row
        lcd_command(0xC0); // Position cursor at 2nd Row, 1st Column
        lcd_string((const unsigned char *)humidity_str, strlen(humidity_str));
    }
}
Are you sure want to unlock this post?
Unlock left : 0
Are you sure want to cancel subscription?
-
00:00
00:00
Update Required Flash plugin
-
00:00
00:00