Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
void main()
{
TRISA=0x01; // Configure RA0 as input pin
LATA=0;
TRISB=0; // Configure Port B as output port
LATB=0;
TRISD=0;
LATD=0;
lcd_ini(); // LCD initialization
while(data[i]!='\0')
{
lcddata(data[i]); // Call lcddata function to send character one by from 'data' array
i++;
}
adc_init(); //ADC Initialization
while(1)
{
temp=0;
for(i=0;i<10;i++)
{
ADCON0|=(1<<GO); // Start A/D conversion
while(!(ADCON0 & (1<<GO))); // Wait until conversion gets over
digital_out[i]=((ADRESL)|(ADRESH<<8)); // Store 10-bit output into a 16-bit variable
Delay_ms(20);
temp=temp+digital_out[i];
}
avg_output=temp/10; // Take average of ten digital values for stablity
adc_con(avg_output); // Function to convert the decimal vaule to its corresponding ASCII
}
}
void adc_init()
{
ADCON1=0x0E; // Make RA0/AN0 pin as analog pin (Other pins remain to be digital I/O)
ADCON0=0x00; // Select Channel0 & ADC off
ADCON2=0x8A; // Left justified, 2TAD acquiciation time, Fosc/32 clock option
ADCON0.ADON=1; // Enable ADC
}
void lcd_ini()
{
lcdcmd(0x38); // Configure the LCD in 8-bit mode, 2 line and 5x7 font
lcdcmd(0x0C); // Display On and Cursor Off
lcdcmd(0x01); // Clear display screen
lcdcmd(0x06); // Increment cursor
lcdcmd(0x80); // Set cursor position to 1st line, 1st column
}
void adc_con(unsigned int adc_out)
{
unsigned int adc_out1;
int i=0;
char position=0xC3;
for(i=0;i<=3;i++)
{
adc_out1=adc_out%10; // To exract the unit position digit
adc_out=adc_out/10;
lcdcmd(position);
lcddata(48+adc_out1); // Convert into its corresponding ASCII
position--;
}
}
void lcdcmd(unsigned char cmdout)
{
lcdport=cmdout; //Send command to lcdport=PORTB
rs=0;
rw=0;
en=1;
Delay_ms(10);
en=0;
}
void lcddata(unsigned char dataout)
{
lcdport=dataout; //Send data to lcdport=PORTB
rs=1;
rw=0;
en=1;
Delay_ms(10);
en=0;
}
i want to display different values from sensor through PIC18f4520 in lcd. im using embedded c language.plzz help me by sending the code
which compiler to be used ur project?...pls send to the full detail ....
what sensor u using ? TC74 ?
- - - Updated - - -
https://ww1.microchip.com/downloads/en/devicedoc/mplab_c18_libraries_51297f.pdf
use this link to learn I2C
do you have a schematic ? if have upload to the forum
its very hard for the others users to see this kind.
what u give was a pin assignment diagram..