Advertisement
Guest User

Untitled

a guest
Dec 11th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #define F_CPU 7372800UL
  2.  
  3. #include <avr/io.h>
  4. #include <avr/interrupt.h>
  5. #include <util/delay.h>
  6.  
  7. void debouncer(){
  8. _delay_ms(200);
  9. GIFR = _BV(INTF0) | _BV(INTF1);
  10. }
  11.  
  12. void blink(){
  13. uint8_t i;
  14. for(i=0; i<10; i++){
  15. //PORTA ^= 0xff; // ovo radi
  16. PORTA = ~PORTA; // ovo ne
  17. _delay_ms(250);
  18. }
  19. }
  20.  
  21. ISR(INT0_vect){
  22. if(PORTA == 0x00){
  23. blink();
  24. }
  25.  
  26. PORTA = PORTA << 1;
  27.  
  28. debouncer();
  29. }
  30. ISR(INT1_vect){
  31. PORTA = PORTA >> 1;
  32. PORTA |= 0x80;
  33. debouncer();
  34. }
  35.  
  36.  
  37.  
  38. int main(void){
  39.  
  40. DDRA = 0xff;
  41. PORTA = 0xff;
  42.  
  43. MCUCR = _BV(ISC01) | _BV(ISC11);
  44. GICR = _BV(INT0) | _BV(INT1);
  45.  
  46. sei();
  47.  
  48. while(1){
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement