#include <lpc214x.h>
#include <stdio.h>

int j;
char charArray[5];
void delay(unsigned int i)
{
int j,k;
for(j=0;j<i;j++)
for(k=0;k<1275;k++);
}

int main()
{
char a;
unsigned int adc;
PINSEL2 = 0;
PINSEL1 = (1U << 24);
AD0CR = (1U << 1) | (3U << 8) | (1U << 21);
PINSEL0=0X00000005 ; //Configuring p0.0 and p0.1 for serial communication
U0LCR = 0X83;// make DLAB 1 for setting baud rate
U0DLM=0X00;
U0DLL=0X61; //setting for making baud rate 9600
U0LCR=0X03; //making DLAB 0 for serial communication
while(1)
{
AD0CR |= (1U << 24); // start conversion
while((AD0GDR & (1U << 31)) == 0);
adc = (AD0GDR >> 6) & 0x3FF;
sprintf(charArray, "%d", adc);
for(j = 0; j < 5; j++){
U0THR = charArray[j];
delay(500);
}
U0THR = ' ';
delay(500);
while(!(U0LSR &0X40)); //checking whether transmitted buffer is empty
}
}
