Advertisement
RuiViana

Interrupt de Serial

Nov 17th, 2015
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include <avr/interrupt.h>
  2. #include <avr/io.h>
  3. void setup()
  4. {
  5. pinMode(13, OUTPUT);
  6.  
  7. UBRR0H = 0; // Load upper 8-bits of the baud rate value into the high byte of the UBRR register
  8. UBRR0L = 8; // Load lower 8-bits of the baud rate value into the low byte of the UBRR register
  9. UCSR0C |= (1 << UCSZ00) | (1 << UCSZ10); // Use 8-bit character sizes
  10. UCSR0B |= (1 << RXEN0) | (1 << TXEN0) | (1 << RXCIE0); // Turn on the transmission, reception, and Receive interrupt
  11. interrupts();
  12. }
  13.  
  14. void loop()
  15. {
  16.  
  17. }
  18.  
  19. ISR(USART0_RX_vect)
  20. {
  21. digitalWrite(13, HIGH); // set the LED on
  22. delay(1000); // wait for a second
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement