Some points.
1. Indentation is vital.
Code:
#include <p18f14k22.h>
#pragma config FOSC = IRC
#pragma config WDTEN = OFF
#pragma config LVP = OFF
const rom unsigned char table_7_segm[] = {
0x5F, //0
0x06, //1
0x3B, //2
0x2F, //3
0x66, //4
0x6D, //5
0x7D, //6
0x07, //7
0x7F, //8
0x6F, //9
0x01,
};
#pragma code
void delay(unsigned int ms)
{
unsigned int i;
for (i = 0; i < 332; i++);
}
void main(void)
{
float skaicius = 0;
char indikatorius = 0;
char i = 0;
OSCCONbits.IRCF2 = 1;
OSCCONbits.IRCF1 = 1;
OSCCONbits.IRCF0 = 1;
ANSEL = 0b0000100;
ANSELH = 0b0000;
PORTA = 0;
TRISA = 0b00100;
PORTB = 0;
TRISB = 0;
PORTC = 0;
TRISC = 0;
ADCON1 = 0x00;
ADCON2 = 0b10111101;
ADCON0 = 0b00001001;
while (1) {
ADCON0bits.GO = 1;
while (ADCON0bits.GO == 1);
skaicius = ((unsigned int) ADRESH << 8) | (unsigned int) ADRESL;
skaicius = skaicius * 40.88;
skaicius += 0.5;
skaicius = skaicius / 1000;
indikatorius = 0x80;
for (i = 0; i < 4; i++) {
LATC = table_7_segm[(int) (skaicius)];
skaicius = skaicius - (int) skaicius;
skaicius = skaicius * 10;
LATB = indikatorius;
if (i == 1)
PORTCbits.RC7 = 1;
delay(5);
LATB = 0;
indikatorius = indikatorius >> 1;
}
}
}
2. Your schematics don't show where the thermometer or fan are connected.
3. When posting technical drawings (as images), use PNG format rather than JPG.
JPG is for natural images. If you compress digital drawings with JPG, then all the fine detail gets fuzzed to the point of being unreadable.