here is code. i am using hc05 module. i want to golw LED using hc05 in atmega8. but somehow not able to interface them. pls helpppppppppppppp!!
#include <avr/io.h>
#include <util/delay.h>
void USART_Init( unsigned int ubrr)
{
/* Set baud rate */
UBRRH = (unsigned char)(ubrr>>8);
UBRRL = (unsigned char)ubrr;
/* Enable receiver and transmitter */
UCSRB = (1<<RXEN)|(1<<TXEN);
/* Set frame format: 8data, 2stop bit */
UCSRC = (1<<URSEL)|(1<<USBS)|(3<<UCSZ0);
}
void USART_Transmit( unsigned char data )
{
/* Wait for empty transmit buffer */
while ( !( UCSRA & (1<<UDRE)) )
;
/* Put data into buffer, sends the data */
UDR = data;
}
unsigned char USART_Receive( void )
{
/* Wait for data to be received */
while ( !(UCSRA & (1<<RXC)) )
;
/* Get and return received data from buffer */
return UDR;
}
int main() {
DDRD=0b11111100;
//int m,n,o,p;
unsigned char e;
USART_Init(51);
while(1) {
e=USART_Receive();
USART_Transmit(e);
if(e=='a')
{PORTD^=0x08;
}
if(e=='b'){
PORTD^=0x10;
}
if(e=='c'){
PORTD^=0x20;
}
if(e=='d'){
PORTD^=0x40;
}
}
}