CODE:#include <avr/io.h>
#include <avr/delay.h>
#include <avr/iom8.h>
#include <avr/interrupt.h>
#include <avr/signal.h>
#define F_CPU 8000000UL // 8 MHz
volatile int modulation=7201; // модулятор
SIGNAL(SIG_OVERFLOW0)
{
TCNT0 = 0;
if(modulation<109)
{
PORTB ^= 0b00000010;
}
else
{
PORTB &= 0b00000000;
}
if(modulation<7200)
{modulation++;}
else
{
modulation=0;
}
}
}
void init_timer0 ()
{cli();
TCNT0 = 222;
TCCR0 = 1;
TIMSK = 1;
sei();
}
Как-то вот так.
Светодиод на ножке В1 |