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 do I put a comma in a decimal number and place it on the screen of the LCD?

Status
Not open for further replies.

Winch

Member
How do I put a comma in a decimal number and place it on the screen of the LCD?
I read an AD input and would like to insert a comma in the result. (see the code)

Code:
Adcin 0, an0  'read AN0 and write value to AN0

    Lcdcmdout LcdLine1Pos(12)
    Lcdout #an0

    Lcdcmdout LcdLine1Pos(1)
    Lcdout "Volt"
        pc1 = an0 * 6 / 10
            Lcdcmdout LcdLine1Pos(6)
    Lcdout #pc1
        WaitMs 250
    Lcdcmdout LcdClear

Goto main
End
 
I am not entirely sure what you want but

Lcdout ","

will place a comma in the next location... If you want to place a comma in the decimal number you will need to split it up!!!

Show me an example output of what you need.... ie

Volt 1,024

If this is what you need I would use a function to build a string...
 
Yes, I need your example of the "volt 1,024"
Basicly I reed the AD converter and set the code to the right voltage.
In this proces I need that comma in the end result!
I was hoping that there was a special code for this kind of problem.
What is your idea of the string?
 
I wrote a floating point LCD out function ( before Vladimir included singles )

Code:
number(5) as byte

number(0) = value / 1000 MOD 10 + 48
number(1) = ","
number(2) = value /100 MOD 10 + 48
number(3) = value /10 MOD 10 + 48
number(4) = value MOD 10 + 48
number(5) = 0

for x = 0 to 5
   Lcdout #number(x)
next x

Something like this
 
Dear Ian,
I try your solution but it doesn't work?
I see what you are doing but it works like a counter!

At the end I write the next code (see below)

Code:
main:  'endless loop

Adcin 0, an0  'read AN0 and write value to AN0

    Lcdcmdout LcdLine2Pos(12)  'write from position 12
    Lcdout #an0  'just to see on the screen what the digital number is!

    Lcdcmdout LcdLine1Pos(1)  'write from first position
    Lcdout "Volt"  'write the word "volt" on the screen!
   
        pc0 = an0 * 594 / 100000 Mod 10
    Lcdcmdout LcdLine1Pos(6)
    Lcdout #pc0

        pc1 = an0 * 594 / 10000 Mod 10
    Lcdcmdout LcdLine1Pos(7)
    Lcdout #pc1

    Lcdcmdout LcdLine1Pos(8)
    Lcdout ","

        pc2 = an0 * 594 / 1000 Mod 10
    Lcdcmdout LcdLine1Pos(9)
    Lcdout #pc2

Goto main
End
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top