Advertisement
Guest User

Untitled

a guest
Oct 13th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #define FOSC 16000000
  2. #define BAUD 9600
  3. #define MYUBRR FOSC/16/BAUD-1
  4.  
  5. ISR(USART_RX_vect){
  6. uint8_t result = UDR0;
  7. switch(result){
  8. case '1':
  9. PORTB |= (1 << PB3);
  10. break;
  11.  
  12. case '2':
  13. PORTB &= ~(1 << PB3);
  14. break;
  15. }
  16. }
  17.  
  18. void USART_Init( unsigned int ubrr){
  19. UBRR0H = (unsigned char)(ubrr>>8);
  20. UBRR0L = (unsigned char)ubrr;
  21. UCSR0B = (1 << RXCIE0) | (1 << RXEN0);
  22. UCSR0C = (1 << UCSZ01) | (1 << UCSZ00);
  23. }
  24.  
  25.  
  26. void setup() {
  27. DDRB = 1 << PB3;
  28. USART_Init(MYUBRR);
  29. sei();
  30. }
  31.  
  32. void loop() {
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement