Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<avr/io.h>
- #include<avr/delay.h>
- #include <avr/interrupt.h>
- #define F_CPU 1000000L
- void main()
- {
- TCCR0 = ((1<<COM01) | (1<<COM00) | (1<<WGM01) | (1<<WGM00) | (1<<CS01));
- TCNT0 = 0;
- DDRB = _BV(3);
- OCR0 = 0;
- int dec = 0;
- int counter = 0;
- PORTA = _BV(3);
- while(1==1)
- {
- if(TIFR & (1 << OCF0))
- {
- //TIFR |= 1<<OCF0;
- counter++;
- if(counter == 3000)
- {
- if(OCR0 == 0)
- dec = 0;
- if(OCR0 == 255)
- dec = 1;
- if(dec)
- OCR0 -= 5;
- else
- OCR0 += 5;
- counter = 0;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement