Advertisement
Guest User

Untitled

a guest
Jan 2nd, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <avr/io.h>
  2. #include <avr/interrupt.h>
  3. #include <util/delay.h>
  4.  
  5. #define BLINK_DELAY_MS 500
  6.  
  7. ISR (INT0_vect){
  8. // switch pin 0 of PORTB while leaving the rest as is
  9. PORTB ^= (1 << PORTB5);
  10. }
  11. int main (void){
  12. DDRB |= (1 << DDB5);
  13. DDRD &= ~(1 << DDD2);
  14. PORTD |= (1 << PORTD2);
  15.  
  16. //set INT0 to trigger on falling edge
  17. EICRA |= (1 << ISC01);
  18. //Turns on INT0
  19. EIMSK |= (1 << INT0);
  20. //SEt Interrupts
  21. sei();
  22. while(1) {
  23. PORTB ^= 1 << PORTB5;
  24. _delay_ms(BLINK_DELAY_MS);
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement