Код: Выделить всё
#define F_CPU 8000000UL
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
void pwm_settings()
{
// PWM SETTINGS
TCCR1A |= (1 << COM1A1)|(0 << COM1A0)
|(1 << WGM11)|(1 << WGM10);
TCCR1B |= (1 << WGM12)|(1 << WGM13)|(0 << CS12)|(1 << CS11)|(0 << CS10);
TCNT1 = 0x00;
ICR1 = 0xFF;
OCR1A = 0x00;
};
int main(void)
{
unsigned char d=0;
DDRA &= ~((1<<PA0)|(1<<PA1));
PORTA |=(1<<PA0)|(1<<PA1);
DDRD |=(1<<PD5);
void pwm_settings();
while(1)
{
if (0== (PINA&(1<<0)))
{
for(d=0; d<255; d++)
{
OCR1A = d;
_delay_ms(30);
}
}
if (0== (PINA&(1<<1)))
{
for(d=0; d>255; d--)
{
OCR1A = d;
_delay_ms(30);
}
}
}
}


