Kod: Zaznacz cały
\
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
int main(void)
{
DDRB=0b11111100;
PORTB=0;
TCCR1B |= (1 << WGM12);
TIMSK |= (1 << OCIE1A);
OCR1A = 1000 ;
TCCR1B |= (1 << CS10);
TCCR1B&=~((1<<CS11)|(1<<CS12));
sei();
for(;;)
{
if(!(PINB & 0b00000001))
{
OCR1A++;
}
if(!(PINB & 0b00000010))
{
OCR1A--;
}
_delay_ms(1);
}
}
ISR(TIMER1_COMPA_vect)
{
PORTB^=_BV(2);
}