Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <avr/io.h>
- int main(){
- DDRB |=1 << PINB0;
- int baud = 25;
- UBRRH = (unsigned char)(baud>>8);
- UBRRL = (unsigned char)baud;
- UCSRB = (1<<RXEN)|(1<<TXEN);
- /* Set frame format: 8data, 2stop bit */
- UCSRC = (1<<URSEL)|(1<<USBS)|(3<<UCSZ0);
- unsigned char rd;
- while(1){
- while (! (UCSRA & (1 << RXC)) );
- rd = UDR;
- if(rd==0b10101010){
- PORTB ^=1 << PINB0;
- PORTB &=~(1<<PINB1);
- }
- else{
- PORTB |=1 << PINB1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement