LCD without zero

Status
Not open for further replies.

aduri

New Member
Hello,
This code (Mikrobasic) converts an analogical value in a binary for a radio frequency control.


This's the code:


This is my problem:


When the value is lower than 10 (e.g. 9), I'd like the LCD to visualise the number 09
I tried with the IF code, but it doesn't work.

Ciao
Antonio
 
Last edited:
Can you change the second if to,
Code:
if (ValoreAdc1<10) then ValoreADC=9 '
end if

Mike.
 
Are you trying to pad single digit numbers with a leading '0'? A little more code and sure we can help.
 
Manily needed is:

bytetostr
LCD_out

we need to see how these work to show you how to pad it.

Also i assume that "ValoreAdc1" is normal DEC and not BCD.

so :

Code:
cod_fine:
    byteAdcbin1 = Dec2Bcd16(ValoreAdc1) ' conversione da decimale a binario
    if (ValoreAdc1 == 0) then
        portb=255 'led or contraves on pins 32 to 40
    else
        if (ValoreAdc1 <= 99)
            then portb = not byteAdcbin1
        end if
    end if

    if (ValoreAdc1 >= 100) then
        ValoreAdc1 == 99 '
    end if
    if (ValoreAdc1 <= 9) then
        LCD_out(1,11,"0") 'wouldnt this have to be [b]LCD_out(1,09,"0")[/b]
    end if                'i say the above because you want the 0 before 
                          'the 10th character aka 9th character

    bytetostr(ValoreAdc1,txt1)
    LCD_out(1,10,txt1)    'assuming that this is the 10th character on screen

I changed the if = to if == also some if < to if <=

also since this is basic i dont know much really but should a single char be in single quotes '0' not "0", if all failes try 0x30 :

LCD_out(1,09,'0') or LCD_out(1,09,0x30) should be the same thing a (0)
 
Last edited:
Thank you,
I solved with this code.


Code:
bytetostr(ValoreAdc1,txt1) 
       if (ValoreAdc1<10) then txt1[1] = "0" 
       end if 
  LCD_out(1,10,txt1)



Ciao
Antonio
 
If you know a better method, I'd be very pleased to have alternative solution.

Bye
Antonio
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…