Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <avr/io.h>
- #include <util/delay.h>
- // LED på OCR0A
- // Bonans fyr ISO WRG 6s
- int main(void)
- {
- TCCR0A = (1 << COM0A1) | (0 << COM0A0)
- | (0 << COM0B1) | (0 << COM0B0)
- | (1 << WGM01) | (1 << WGM00);
- TCCR0B = (0 << WGM02)
- | (0 << CS02) | (0 << CS01) | (1 << CS00);
- OCR0A = 0;
- DDRB |= (1 << PB0);
- while (1)
- {
- /* ramp up */
- while (OCR0A < 255)
- {
- OCR0A ++;
- _delay_ms(4); // ca 1 sekund
- }
- _delay_ms(5000);
- /* ramp down*/
- while (OCR0A > 0)
- {
- OCR0A --;
- _delay_ms(4); // ca 1 sekund
- }
- _delay_ms(5000);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment