Advertisement
Guest User

Untitled

a guest
Sep 8th, 2013
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1.  
  2.  
  3. #include <avr/io.h>
  4.  
  5. int main(){
  6. DDRB |=1 << PINB0;
  7. int baud = 25;
  8. UBRRH = (unsigned char)(baud>>8);
  9. UBRRL = (unsigned char)baud;
  10.  
  11. UCSRB = (1<<RXEN)|(1<<TXEN);
  12. /* Set frame format: 8data, 2stop bit */
  13. UCSRC = (1<<URSEL)|(1<<USBS)|(3<<UCSZ0);
  14. unsigned char rd;
  15.  
  16. while(1){
  17. while (! (UCSRA & (1 << RXC)) );
  18. rd = UDR;
  19. if(rd==0b10101010){
  20. PORTB ^=1 << PINB0;
  21. PORTB &=~(1<<PINB1);
  22. }
  23. else{
  24. PORTB |=1 << PINB1;
  25. }
  26.  
  27.  
  28. }
  29.  
  30.  
  31.  
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement