Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define F_CPU 7372800UL
- #include <avr/io.h>
- #include <util/delay.h>
- #include <avr/interrupt.h>
- static uint8_t counter = 0;
- static uint8_t flag = 0;
- void debounce(){
- _delay_ms(300);
- GIFR = _BV(INTF0) | _BV(INTF1);
- }
- ISR(INT1_vect){
- PORTA = PORTA << 1;
- PORTA |= 0x01;
- debounce();
- }
- ISR(INT0_vect){
- PORTA = PORTA >> 1;
- if(PORTA == 0x00){
- flag = 1;
- }
- debounce();
- }
- void aktivnost(){
- if(counter == 10){
- flag = 0;
- counter = 0;
- return;
- }
- if(counter < 10){
- PORTA = ~PORTA;
- counter++;
- }
- }
- int main(void){
- PORTA = 0xff;
- DDRA = 0xff;
- MCUCR = _BV(ISC11) | _BV(ISC10) | _BV(ISC01) | _BV(ISC00);
- GICR = _BV(INT0) | _BV(INT1);
- sei();
- while (1) {
- if(flag == 1){
- aktivnost();
- }
- _delay_ms(300);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement