//udara manoj******PIC16F84****4MHZ****
//2010.12.21
unsigned int temp_res;
void ssdcode(int i);
int Digit1; // Variable for digit1
int Digit2; // Variable for digit2
int Digit3; // Variable for digit3
int number;
void main(){
TRISA = 0b00000100; //RA2 input
TRISB = 0; //PORTB output
number = 0; //Start from 0
Digit1 = 0; //Start from 0
Digit2 = 0; //Start from 0
Digit3 = 0; //Start from 0
do {
temp_res = ADC_Read(2); // Get 10-bit results of AD conversion
number=temp_res*0.00489; //digital count multiply by resolution *** you can multiply this part what ever your input voltage ..but keep in mind real cct u should add voltage divider
Digit1 = number%10; //Remainder
Digit2 = number/10; //division
Digit3= number/100; //divition
ssdcode(Digit1); //Display digit 1
PORTA.F0 = 1; //Enable Digit1
Delay_ms(10); //Small delay
PORTA.F0 = 0; //Disable Digit1
ssdcode(Digit2); //Display digit 2
PORTA.F1 = 1; //Enable Digit2
Delay_ms(10); //Small delay
PORTA.F1 = 0; //Disable Digit2
ssdcode(Digit3); //Display digit 2
PORTA.F3 = 1; //Enable Digit2
Delay_ms(10); //Small delay
PORTA.F3 = 0; //Disable Digit2
}
while(1);
}
void ssdcode(int i){
switch (i){
case 0: PORTB = 0b00111111; break;
case 1: PORTB = 0b00000110; break;
case 2: PORTB = 0b01011011; break;
case 3: PORTB = 0b01001111; break;
case 4: PORTB = 0b01100110; break;
case 5: PORTB = 0b01101101; break;
case 6: PORTB = 0b01111101; break;
case 7: PORTB = 0b00000111; break;
case 8: PORTB = 0b01111111; break;
case 9: PORTB = 0b01101111; break;
}
}