Actions

Talk

Avr2011 Programming The Kit: Difference between revisions

From HacDC Wiki

No edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 3: Line 3:
Light Em' Up Program
Light Em' Up Program


  #include <avr/io.h>
  #include <avr/io.h> /* AVR library to define pins, ports, etc */
#define F_CPU 8000000UL      
  int main(void)
#include <util/delay.h>
{
 
DDRB = 0xff; //Set port B pins as all outputs
  void main(void){
PORTB = 0xff; //Set all Port B pins as High
  DDRB = 0b11111111;
return 1;
 
  while(1){
    PORTB = 0b11111111;
  } 
  }
  }

Latest revision as of 23:45, 12 March 2011

I find it helpful to flash the chip with a simple program to turn on all LED's just to ensure all of your LED's work before moving on just in case you put an LED in backwards.

Light Em' Up Program

#include <avr/io.h> /* AVR library to define pins, ports, etc */
int main(void)
{
	DDRB = 0xff;  //Set port B pins as all outputs
	PORTB = 0xff; //Set all Port B pins as High
	return 1;
}