Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Need c code about number system converter

Status
Not open for further replies.

SMUDGE

Newbie level 1
Joined
Jul 25, 2012
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,295
My project is number system converter which means you enter decimal base on your choice to convert to binary or oct. Or you enter binary base on your choice to convert to decimal or oct. Or you enter oct base on your choice to convert to decimal or binary. If you want to convert from binary to decimal, but you enter the decimal, the buzzer will turn on. If the number is converted to the decimal, the red LED will light. oct-Green LED will light. Binary- Yellow LED will light. Once the number you entered is decimal, this number must display on the 7-segment. Otherwise, display on the LCD. Once the number is converted is decimal, this decimal number also displays on the 7-segment. Overall, Once the number is decimal, it should be displayed on the LCD.The microchip is p18f4520.So can someone can help me about the c code. I really do not have any idea about it. Thanks so so so much!
 

this should help you in your c program it convert from decimal to binary
the following is a c# program
Code:
namespace _01.Decimal_to_Binary 
{ 
    class DecimalToBinary 
    { 
        static void Main(string[] args) 
        { 
            Console.Write("Decimal: "); 
            int decimalNumber = int.Parse(Console.ReadLine()); 
 
            int remainder; 
            string result = string.Empty; 
            while (decimalNumber > 0) 
            { 
                remainder = decimalNumber % 2; 
                decimalNumber /= 2; 
                result = remainder.ToString() + result; 
            } 
            Console.WriteLine("Binary:  {0}",result); 
        } 
    } 
}
 

This is the function:

input: string (texto)
ouput: int



Code C - [expand]
1
2
3
4
5
6
7
8
9
int deBinario(char * texto){
        int longitud = strlen(texto);
        int valorMenosSignificativo = texto[longitud - 1] - '0';
        texto[longitud - 1] = 0;
        if (longitud == 1)
            return valorMenosSignificativo;
        else
            return valorMenosSignificativo + 2 * deBinario(texto);
    }



enjoy
 

Hi,

First of all you project is divided in three parts
1) PIC micro controller based hardware
2) Develop the PIC micro controller based logic development for the mathematical operations
3) Testing of the operation ( requirement )

Now here will be my thought try to develop the hardware first Follow the steps -
1) First of all what you need a LCD(as you mentioned in the post) interfaced with PIC micro-controller
2) In order to enter the number in the code you need ti have at least 4x4 key board interfaced to the board as in Hex number system you have 0 to F as number input
3) you need to have number enter switch and number convert switches interfaced to the micro controller
4) then you need to have select num switch and binary, hex and decimal and oct num ( Five switch) and same Five for convert select num system....( total 10 switch)
5) and then the four LED's....

As I understand the your requirement....I think let's wait for some more posts from some expert for such a design of num system design...

Good Luck
 

My project is number system converter which means you enter decimal base on your choice to convert to binary or oct. Or you enter binary base on your choice to convert to decimal or oct. Or you enter oct base on your choice to convert to decimal or binary.

Well this part is easy I will give you a hint use modulo operator('%').

after you successfully tried iit on the PC port it to your controller and see if the results are correct.
then flesh out the code to validate if the input is valid for the selected mode or not and beep the buzzer.


If you want to convert from binary to decimal, but you enter the decimal, the buzzer will turn on. If the number is converted to the decimal, the red LED will light. oct-Green LED will light. Binary- Yellow LED will light. Once the number you entered is decimal, this number must display on the 7-segment. Otherwise, display on the LCD. Once the number is converted is decimal, this decimal number also displays on the 7-segment. Overall, Once the number is decimal, it should be displayed on the LCD.The microchip is p18f4520.So can someone can help me about the c code. I really do not have any idea about it. Thanks so so so much!

For hardware designer I am very poor, hence I can't suggest any :):-?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top