Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <avr/io.h>
- #include <util/delay.h>
- int main(void)
- {
- DDRD|=((1<<PD0)|(1<<PD1)|(1<<PD2)|(1<<PD3)); //wyjscia mostek h
- DDRD|=((1<<PD5)|(1<<PD4)); //wyjscia PWM_1AB
- TCCR1A|=((1<<COM1A1)|(1<<COM1B1)); //fast_PWM
- TCCR1A|=((1<<WGM12)|(1<<WGM10));
- TCCR1B|=((1<<CS11)|(1<<CS10)); //prescaler 64
- OCR1A=0;
- OCR1B=0;
- PORTD|=((1<<PD0)|(1<<PD2));
- PORTD&=~((1<<PD1)|(1<<PD3));
- while (1)
- {
- uint8_t i;
- while(i<250)
- {
- OCR1A=OCR1B=i;
- i+=10;
- _delay_ms(100);
- }
- while(i>0)
- {
- OCR1A=OCR1B=i;
- i-=10;
- _delay_ms(100);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement