Sign In

Code Works In Proteus Software But Not In A Circuit

Sabthavi Sri Lanka

Hardware: PIC16F877A (4MHz) Software: MPLAB X IDE XC8 Compiler

Hi sir,
Our following code works in proteus software correctly. but in the circuit it works in the opposite way(when we power up the circuit the LED which has to blink after reaching 75 degree blinks at room temperature )
we have to submit our project within 1 week.Help us as soon as possible sir.



#define _XTAL_FREQ 4000000
#include <stdio.h>
#include <stdlib.h>
#pragma config FOSC = HS       // Oscillator Selection bits (HS oscillator)
#pragma config WDTE = OFF       // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = OFF      // Power-up Timer Enable bit (PWRT disabled)
#pragma config BOREN = OFF       // Brown-out Reset Enable bit (BOR enabled)
#pragma config LVP = OFF        // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit (RB3/PGM pin has PGM function; low-voltage programming enabled)
#pragma config CPD = OFF

void main()     // main program begins
    double value;
    TRISA = 0b11111111; // initialize Port A as an input port
    TRISC = 0b00000000; // initialize Port C as an Output port
    PORTC = 0b00001100;// exhaust fan switches on 
        ADCON0 = 0b11000001; 
        ADCON1 = 0b10000000;
        value = (ADRESH << 8) + ADRESL; 
        value = (value * 5.0)/ 1023.0;  // Equivalent voltage for the temperature
        value = value * 100.0;            // Temperature in Celcius 
        PORTC = 0b00000011;     

Post a reply to Sabthavi

Think you can help Sabthavi ? Then post your thoughts that might help Sabthavi. You will earn a lot of reputation in the technical community.

If your program is in multiple files, then ZIP the entire folder and attach below

Images and Screenshots

These helps other better understand your suggestion.