hc 05 with atmega16
#1

request / requirement / hc 05 with atmega16
Reply
#2

#define F_CPU 12000000UL
#define USART_BAUDRATE 9600 // Baud Rate value
#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1)

#include
#include

#define LCD_DATA PORTA //LCD data port


void usart_init();
unsigned int usart_getch();

int main()
{
unsigned char value;
DDRA=0b00000011; // LCD_DATA port as output port
_delay_ms(50); // delay of 50 milli seconds
usart_init(); // initialization of USART
while(1)
{
value=usart_getch(); // Call a function to get data from serial port
if(value == '1') {PORTA = 0b00000001; _delay_ms(1000); }
else if (value == '2') {PORTA = 0b00000010; _delay_ms(1000); }
else PORTA = 0b00000011;
}
return 0;
}



void usart_init()
{
UCSRB |= (1 << RXEN) | (1 << TXEN); // Turn on the transmission and reception circuitry
UCSRC |= (1 << URSEL) | (1<<USBS) | (1 << UCSZ0) | (1 << UCSZ1);
// Use 8-bit character sizes

UBRRL = BAUD_PRESCALE;
// Load lower 8-bits of the baud rate value into the low byte of the UBRR register
UBRRH = (BAUD_PRESCALE >> 8); // Load upper 8-bits of the baud rate value..
// into the high byte of the UBRR register
}

unsigned int usart_getch()
{
while ((UCSRA & (1 << RXC)) == 0);
// Do nothing until data has been received and is ready to be read from UDR
return(UDR); // return the byte
}
Reply

Important Note..!

If you are not satisfied with above reply ,..Please

ASK HERE

So that we will collect data for you and will made reply to the request....OR try below "QUICK REPLY" box to add a reply to this page

[-]
Quick Reply
Message
Type your reply to this message here.

Image Verification
Please enter the text contained within the image into the text box below it. This process is used to prevent automated spam bots.
Image Verification
(case insensitive)

Possibly Related Threads...
Thread Author Replies Views Last Post
  maze solving robot atmega16 source code nomi064 3 725 17-05-2016, 07:09 PM
Last Post: Guest
  maze solving robot atmega16 source code 1 537 29-04-2016, 11:46 AM
Last Post: dhanabhagya
  code for wall following robot using atmega16 1 540 25-04-2016, 09:37 AM
Last Post: dhanabhagya
  programming of atmega16 for traic 1 489 12-03-2016, 01:00 PM
Last Post: seminar report asees
  k eypad door lock system using atmega16 pdf 1 529 05-03-2016, 02:06 PM
Last Post: seminar report asees

Forum Jump: