Created
October 1, 2016 14:20
-
-
Save naotaco/f5a436dfefd35a407ca58b724ff33985 to your computer and use it in GitHub Desktop.
LED blink code for AVR
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <avr/io.h> | |
#define F_CPU 8000000UL //8MHz | |
#include <util/delay.h> | |
int main(void){ | |
DDRC = 0x02; // C1 to output | |
CLKPR = (1 << CLKPCE); // Enable clock change | |
CLKPR = 0; // 0 to 1-div clock (max speed = 8MHz) | |
for(;;){ | |
if (PORTC & 0x02){ | |
PORTC &= ~0x02; | |
}else{ | |
PORTC |= 0x02; | |
} | |
_delay_ms(1000); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment