35 lines
591 B
C
35 lines
591 B
C
#include "delay.h"
|
|
#include <avr/interrupt.h>
|
|
volatile uint8_t flag=0;
|
|
|
|
int main(void){
|
|
timer1_init();
|
|
DDRC |= (1<<PC0); // PB1 (D9)
|
|
// prescaler 8
|
|
DDRD &= ~(1 << PD2);
|
|
PORTD |= (1 << PD2);
|
|
EICRA &= ~(1<<ISC00);
|
|
EICRA |= (1<<ISC01);
|
|
EIMSK |= (1<<INT0);
|
|
|
|
sei();
|
|
while(1){
|
|
if(flag){
|
|
|
|
flag=0;
|
|
PORTC |=(1<<PC0);
|
|
delay_ms(500);
|
|
PORTC &=~(1<<PC0);
|
|
delay_ms(500);
|
|
}
|
|
else{
|
|
PORTC |=(1<<PC0);
|
|
delay_ms(50);
|
|
PORTC &=~(1<<PC0);
|
|
delay_ms(50);
|
|
} // 75%
|
|
}
|
|
}
|
|
ISR(INT0_vect){
|
|
flag=1;
|
|
} |