Last active
August 29, 2015 13:56
-
-
Save bradfordbarr/9204591 to your computer and use it in GitHub Desktop.
AVR Hello World
This file contains hidden or 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
/* Borrowed from: http://wiki.hacdc.org/index.php/AVR_Lesson:_Output_Pins_I */ | |
/* Blinker Demo */ | |
#include <avr/io.h> /* Defines pins, ports, etc */ | |
#define F_CPU 8000000UL /* Sets up the chip speed for delay.h */ | |
#include <util/delay.h> /* Functions to waste time */ | |
#define LED PB1 /* Defines pin PB4 for the LED. I | |
often incorporate a bunch of the circuit | |
info in the defines, which makes | |
porting the code to another chip | |
easier and reminds you of how to | |
hook it up. */ | |
int main(void){ | |
DDRB = _BV(LED); /* Data Direction Register B: | |
writing a one to the bit | |
enables output. */ | |
while(1){ /* the main loop, from which we never return */ | |
PORTB = _BV(LED); /* Turn on the LED bit/pin in PORTB */ | |
_delay_ms(400); /* wait */ | |
PORTB &= ~_BV(LED); /* Turn off the LED bit/pin in PORTB */ | |
_delay_ms(400); /* wait */ | |
} | |
return(0); /* never reached */ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment