Advertisement
Guest User

Untitled

a guest
Jan 16th, 2016
1,394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #define F_CPU 8000000UL
  2. #include <avr/io.h>
  3. #include <util/delay.h>
  4. #include <avr/interrupt.h>
  5.  
  6. #define BAUD 9600UL
  7. //#define UBRR0_VALUE ((F_CPU/(16*BAUD)) - 1)
  8.  
  9. int main(void)
  10. {
  11. UBRR0H = (51 >> 8);
  12. UBRR0L = 51;
  13.  
  14. UCSR0B = (1<<TXEN0) | (1<<RXEN0);
  15. UCSR0C = (1<<UCSZ00) | (1<<UCSZ01); //8bit
  16.  
  17. DDRD |= (1<<5);
  18.  
  19. while(1)
  20. {
  21. //senden
  22. //UDR0 = '3';
  23. //_delay_ms(1000);
  24.  
  25. //empfangen
  26. while (!(UCSR0A & (1<<RXC0)))
  27. ;
  28. if (UDR0 == 33) //ASCII '!'
  29. {
  30. PORTD |= (1<<5);
  31. }
  32. else
  33. {
  34. PORTD &= ~(1<<5);
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement