Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

how to display ADC value on LCD ? [CCS C Compiler]

Status
Not open for further replies.
Which controller are you using?
Change the below program according to your hardware
HTML:
#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);
}

Best wishes :)
 

i want to display adc value on my lcd

then you need to write some code for getting the value from the adc, and then some for converting the binary number to bcd (with appropriate scaling), and some more code for displaying/ driving the lcD.

All of these are quite standardised, and often available as library functions, depending on the dev platform you are using.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top