Status
Not open for further replies.

#### eessoo

Joined Jan 29, 2012
23
i need some help with this program
if i input 13.3 on the screen and give output 10?
it should give the same output as the input
i wanna take the input from the lcd and do some calculation to it
i'm using pic16f877a
mikroc pro forpic
the input in the lcd is in char
so i take each digit and add it the equation

for example if the user enter (127)

(output=(output*10)+input)
( kp = kp * 10 + kp1)
0 = 0 * 10 + 1 >>kp=1
1 = 1 * 10 + 2 >> kp = 12
12 = 12*10 + 7 >> kp=127
u get it?!

( kp=kp1/10+kp)<<< this only works if u add (.) to your number

Rich (BB code):
int key=0;
float x;
int h=10;
char txt[15];
float kpt=0;

{
switch (key)
{case 9:
key=49;
break;
case 10:
key=50;
break;
case 11:
key=51;
break;
case 5:
key=52;
break;
case 6:
key=53;
break;
case 7:
key=54;
break;
case 1:
key=55;
break;
case 2:
key=56;
break;
case 3:
key=57;
break;
case 13:
key=13;
break;
case 14:
key=48;
break;
case 15:
key=46;
}
return (key);
}
// Lcd pinout settings
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D4 at RB0_bit;

// Pin direction
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D7_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB0_bit;

void main() {

lcd_init();
while(1)
{
do
while(!key);
if(key==13)
{
lcd_cmd(_lcd_clear);
break;
}

else if(key==46)
{
while(1)
{lcd_chr_cp(key);
do
while(!key);
kpt=((key-48)/10)+kpt;

if(key==13)
{lcd_cmd(_lcd_clear);
goto finaly;}

}
break;
}
else if(key!=13)
{lcd_chr_cp(key);
kpt=kpt*10+(key-48);}
}
finaly:
floattostr(kpt,txt);
Lcd_Out_CP(txt);
}

Last edited:

#### hgmjr

Joined Jan 28, 2005
9,027
This does seem to be a double posting.

Duplicate posts can only result in confusion.

hgmjr

Status
Not open for further replies.