[SOLVED] How to hide first time running digit 00.00

Status
Not open for further replies.

sacban

Junior Member level 3
Joined
Aug 20, 2015
Messages
29
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
412
Hello Everyone,
I made a project for a volt meter, this project already working fine, just I want to change the method during first time running.

First time running, I got digit 00.00 onto LCD appears, then once the voltage read source voltage "example 4,5 volt" the digit reading for 04.50, this is true, how can I change that way, when first time running the digit never show digit 00.00, then once have voltage 4.5 volt the digit will show 4.50.

Below are the code :

Code:
void main()
{
 ADCON1=0x82;
 TRISA=0XFF;
 Lcd_Init();
 lcd_cmd(_LCD_CLEAR);
 lcd_cmd(_LCD_CURSOR_OFF);
 Lcd_Out(1,5," Meter");
 lcd_out(2,1,"VOLT:");
 for(;;){
         adc_value=ADC_Read(0);
         adc_value=adc_value*5000/1023;
         
          hit1=adc_value/1000;
          hit2=(adc_value%1000)/100;
          hit3=((adc_Value%1000)%100)/10;
          hit4=((adc_value%1000)%100)%10;
          
          lcd_chr(2,11,48+hitung1);   
          lcd_chr_cp(hitung2+48);
          lcd_chr_cp('.');
          lcd_chr_cp(48+hitung3);
          lcd_chr_cp(48+hitung4);
          lcd_chr_cp('V');
         
         delay_ms(20);
        }
}


I hope someone there will help me solve this out.

Thank you.
 

Try this. It just needs a if() condition.

Code:
for(;;){
         adc_value=ADC_Read(0);
         adc_value=adc_value*5000/1023;
         
	if(adc_value > 0.0) {
          hit1=adc_value/1000;
          hit2=(adc_value%1000)/100;
          hit3=((adc_Value%1000)%100)/10;
          hit4=((adc_value%1000)%100)%10;
          
          lcd_chr(2,11,48+hitung1);   
          lcd_chr_cp(hitung2+48);
          lcd_chr_cp('.');
          lcd_chr_cp(48+hitung3);
          lcd_chr_cp(48+hitung4);
          lcd_chr_cp('V');
         
         delay_ms(20);
	}
        }
 

Hi,

My thoughts:
* What's wrong when it shows "00.00"?
* there are different variable names. I don't understand howit can work. "hit1" -> "hitung1"
* with the code of post#2 ... it never shows 0. So if you immediately remove the voltage, then it may "01.23" while the input voltage is 0V.
* a delay of 20ms is not useful. Our eyes can't read more than 3-4 values per second, thus a delay of 300ms is more suitable.

Klaus
 

Why not by simply handling digits, writing a space character instead Zero ?
Something like that (eg. for the first digit), not tested :

Code:
if (hitung1)
          lcd_chr(2,11,48+hitung1);   
else
          lcd_chr(2,11, ' ');
 

Hello There,
Thank you for your respond according my question.

As well your suggestion below are :

baileychic : I trying that method but doesn't working.
KlausST : My thoughts:
* What's wrong when it shows "00.00"?
** It's no wrong but more better if the zero hidden before use.

* there are different variable names. I don't understand howit can work. "hit1" -> "hitung1"
** Yes.....you are correct, there is should be hit1 not hitung....

* with the code of post#2 ... it never shows 0. So if you immediately remove the voltage, then it may "01.23" while the input voltage is 0V.
** Yes.....If I go to lower voltage example 9 volt, then will show 09.00

* a delay of 20ms is not useful. Our eyes can't read more than 3-4 values per second, thus a delay of 300ms is more suitable.
** It's ok for the Delay_ms(20), but can change to 300ms.
Thank you......

andre_teprom : I trying your method and that working as well my expected.

Below are the code :





Thank you.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…