armghan11
Member level 1
- Joined
- Oct 9, 2012
- Messages
- 41
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,286
- Activity points
- 1,557
i want to display adc value on my lcd
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.
#include "18F2520.h"
#device adc=10
#fuses INTRC_IO // INTERNAL OSCILLATOR
#use delay(clock=4000000) // 4Mhz
// change the pins according to your hardware
//and port B connected to LCD data pins
#define RS PIN_A2
#define EN PIN_A1
void lcd_init();
void lcd_cmd(unsigned char);
void lcd_data(unsigned char);
unsigned int16 adc_read;
void main()
{
lcd_init();
setup_adc( ADC_CLOCK_INTERNAL);
setup_adc_ports( ALL_ANALOG );
set_adc_channel(4); // select channel according to your hardware
while(1)
{
adc_read = read_adc();
lcd_cmd(0x80);
printf(lcd_data,"%lu",adc_read);
delay_ms(100);
}
}
void lcd_init()
{
lcd_cmd(0x30); // Configure the LCD in 8-bit mode, 1 line and 5x7 font
lcd_cmd(0x0c); // display on and cursor off
lcd_cmd(0x01); // clear display screen
lcd_cmd(0x06); // increment cursor
lcd_cmd(0x80); // set cursor to 1st line
}
void lcd_cmd(unsigned char c)
{
output_b(c); // change port according to your hardware
output_low(RS);
output_high(EN);
delay_ms(15);
output_low(EN);
}
void lcd_data(unsigned char z)
{
output_b(z); // change port according to your hardware
output_high(RS);
output_high(EN);
delay_ms(15);
output_low(EN);
}
i want to display adc value on my lcd