Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save prasant1010/c65242746eebd2914b647fcd6741c021 to your computer and use it in GitHub Desktop.
Save prasant1010/c65242746eebd2914b647fcd6741c021 to your computer and use it in GitHub Desktop.
/*
* one_way_communication_Rx.c
*
* Created: 12/19/2015 6:48:52 PM
* Author: keshab
*/
#define F_CPU 1000000UL
#include <avr/io.h>
#include <util/delay.h>
int main(void)
{
DDRA=0xff;
PORTA=0X00;
int ubrr_value=25;
UBRRH=(unsigned char)(ubrr_value>>8);//0b00000000
UBRRL=(unsigned char)(ubrr_value);
UCSRB=(1<<RXEN)|(1<<TXEN);
UCSRC=(1<<USBS)|(3<<UCSZ0);
unsigned char receiveData;
while(1)
{
receiveData=UDR;
if(receiveData==0b00000001)
{
for (unsigned int i =0 ;i<=5;i++)
{
PORTA|=(1<<PINA0);
}
}
if(receiveData==0b00000010)
{
for (unsigned int i =0 ;i<=5;i++)
{
PORTA|=(1<<PINA1);
}
}
if(receiveData==0b00000011)
{
for (unsigned int i =0 ;i<=5;i++)
{
PORTA|=(1<<PINA2);
}
}
if(receiveData==0b00000100)
{
for (unsigned int i =0 ;i<=5;i++)
{
PORTA|=(1<<PINA3);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment