Skip to content

Instantly share code, notes, and snippets.

@owskio
Last active February 24, 2016 03:00
Show Gist options
  • Save owskio/bcba322a4b95beec3002 to your computer and use it in GitHub Desktop.
Save owskio/bcba322a4b95beec3002 to your computer and use it in GitHub Desktop.
Atmel 328p AVR LED blink simple
/*
sudo avr-gcc -Wall ledBlinkSimple.c -mmcu=atmega328p -o ledBlinkSimple.o
sudo avr-objcopy -O ihex -R .eeprom ledBlinkSimple.o ledBlinkSimple.hex
sudo avrdude -p atmega328p -c avrisp2 -U flash:w:ledBlinkSimple.hex -P /dev/ttyACM0
*/
#define F_CPU 1000000UL //Tell delay.h we're running the default 1 MHz
#include <avr/io.h>
#include <util/delay.h>
int main(void) {
DDRC = 0xFF;
while(1) {
PORTC = 0xFF; //all pins up
_delay_ms(100);
PORTC= 0x00; //all pins down
_delay_ms(100);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment