engr.waqas
Full Member level 3
- Joined
- Jul 21, 2009
- Messages
- 172
- Helped
- 13
- Reputation
- 26
- Reaction score
- 10
- Trophy points
- 1,298
- Location
- karachi,Pakistan
- Activity points
- 2,342
c coding help
I am putting analog input from 0 to 5 v in PIC 18.
Now the A/D result is saved in a register "result" type int.
Now i want to convert the values stored in "result" to ASCII and then to display on LCD.
I have Vref of A/D as 5 volt and using in 10 bit mode.
I want LCD to show fractional values too like 4.5 etc
My coding is
#include <stdio.h>
char buffer[8];
void convert(void)
{
int result;
double voltage;
voltage = (double)(result * 5.0 / 1024.0);
sprintf(buffer, "%0.1f", voltage);
}
i have problem that LCD data lines are connected to port D(D0 to D7).Now when i use the following code to send data stored in buffer[] i get syntax error.
PORTD=buffer[];
so how can i send the value stored in buffer[] to PORT D.
I am putting analog input from 0 to 5 v in PIC 18.
Now the A/D result is saved in a register "result" type int.
Now i want to convert the values stored in "result" to ASCII and then to display on LCD.
I have Vref of A/D as 5 volt and using in 10 bit mode.
I want LCD to show fractional values too like 4.5 etc
My coding is
#include <stdio.h>
char buffer[8];
void convert(void)
{
int result;
double voltage;
voltage = (double)(result * 5.0 / 1024.0);
sprintf(buffer, "%0.1f", voltage);
}
i have problem that LCD data lines are connected to port D(D0 to D7).Now when i use the following code to send data stored in buffer[] i get syntax error.
PORTD=buffer[];
so how can i send the value stored in buffer[] to PORT D.