Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

How to convert the hexadecimal o/p into decimal o/p shows in the 7 segment pic18f4550

hee

New Member
i have meet some problem with my coding in which my ADconverter output program shows the output in 7 segmant in hexadecimal number, but i want in the decimal number...can somebody help me to check my coding how to convert the hexa to decimal output?
View attachment 63749

and my coding
#include <P18F4550.h>
void delay1s(unsigned char);

void main(void)
{
TRISB=0;
TRISAbits.TRISA0=1;
PIR1bits.ADIF=0;
PIE1bits.ADIE=1;
INTCONbits.PEIE=1;
INTCONbits.GIE=1;
ADCON0=00000001;
ADCON1=00001110;
ADCON2=10100101;
ADCON0bits.ADON=0x01;
while(1)
{
ADCON0bits.GO=1;
while(ADCON0bits.DONE==1);
PORTB=ADRESL;
delay1s(1);
}
}


void delay1s(unsigned char nsecond)
{
unsigned char x, y;
for(x=0;x<nsecond;x++) //Total delay
for(y=0;y<200;y++); //No.of loop to generate 1 second delay
}
 
How is it you have only 4 connections to a 7 segment display?

I don't see any code to 'check', there is no attempt to make a conversion. You need math to convert hex to decimal and a look up table to convert decimal to 7 segment then either directly run the 7 segment with 8 pins (incl dp) or use a sipo shift register like a 74hc595 to do it with 3 pins from the mcu.
 
I am assuming that the 7-seg displays have their own internal circuitry and accept a 4-bit input to display 0 - F.

For what you want to display (0-255) you don't have enough digits.
 
Last edited:

Latest threads

New Articles From Microcontroller Tips

Back
Top