UART

void usart_init(void)
{
  UBRR0=(uint8_t)51; //UBRR0H=0;
  /******  Asynchronous mode, 8 bit character with no parity and 1 stop bit *******/
  UCSRB|=(1<<RXEN)|(1<<TXEN);
  UCSRC|=(1<<URSEL)|(1<<UCSZ1)|(1<<UCSZ0); //For UCSRC register selection URSEL bit is set.
}
UDR=ByteToSend;
while(!(UCSRA&(1<<TXC)))
{
;// wait until data send
}

OR

UDR=ByteToSend;
while(!(UCSRA&(1<<UDRE)))
{
;// wait for possible sending
}

void usart_putc(unsigned char c)
{
  while(!(UCSRA&(1<<UDRE)));
  UDR=c;
  while(!(UCSRA&(1<<UDRE)));
}
void usart_puts( char *star)
{
  while(*star)
   {
     usart_putc(*star);
     star++;
   }
}
void usart_puti16(int16_t a)
{
  char s[20];
  itoa(a,s,10);
  usart_puts(s);
}
void usart_putui16(uint16_t a)
{
  char s[20];
  utoa(a,s,10);
  usart_puts(s);
}
void usart_puti32(int32_t a)
{
 char s[20];
 ltoa(a,s,10);
 usart_puts(s);
}
void usart_putui32(uint32_t a)
{
  char s[20];
  ultoa(a,s,10);
  usart_puts(s);
}
void usart_putf(float f)
{
  char s[20];
  dtostrf(f,19,3,s); //19 is the string limit & 3 is after period(.)
  usart_puts(s);
}

  #include<stdio.h>
  char usart[20];
  /****convert whatever data type you want to string******/
  sprintf(usart,”%x”,your_data); 
  usart_puts(usart);

char usart_getc(void)
 {
  while(!(UCSRA&(1<<RXC)))
   {
     ; //wait until receive complete  
   }
  return UDR;
 }
  #include<avr/io.h>
  #include<util/delay.h>
  #include<stdio.h>
  #include"usart.h"
  #include"adc.h"
int main(void)
  {
   usart_init();
   adc_init();
   usart_puts("********************************************\r");
   usart_puts("*********   shani kumar sarkar   ***********\r");
   usart_puts("*********   Read ADC value       ***********\r");
   usart_puts("********************************************\r");
   usart_puts("\r press enter to get ADC value\r");
  while(1)
    {
     if(usart_getc()=='\r')
	   {
		usart_puti16(read_adc(0));
		usart_putc('\r');
	   }
    }
 return 0;
}