LCD without zero-Mikrobasic code for radio frequency control

Status
Not open for further replies.

aduri

Newbie level 4
Joined
Jul 9, 2006
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,329
LCD without zero

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


This's the code:

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<100)  then    portb = not byteAdcbin1
             end if
     end if

       if (ValoreAdc1 >99) then ValoreAdc1 =99  '
       end if
           if (ValoreAdc1<10) then LCD_out(1,11,"0")      '
           end if
     bytetostr(ValoreAdc1,txt1)
     LCD_out(1,10,txt1)

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
 

Re: LCD without zero

Your "0" is getting overwritten by your final LCD_out statement.

Try modifying the string txt1 before you output it:
Code:
     bytetostr(ValoreAdc1,txt1) 
     if (ValoreAdc1<10) then txt1[1] = "0"
     endif
     LCD_out(1,10,txt1)
 

    aduri

    Points: 2
    Helpful Answer Positive Rating
Re: LCD without zero

Thank you,
I solved with your code.

Ciao
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…