Tips and Tricks (14)

Previous Tip & Trick

Smash the miror!

Balau wrote an interesting post on “Programming Arduino Uno in pure C”. This is a pretty good starting point for those who would like to get one step further from Arduino to the whole AVR world!

Here is a look and feel about blink sketch in “pure C”

#include <avr/io.h>
#include <util/delay.h>

enum {
 BLINK_DELAY_MS = 1000,
};

int main (void)
{
 /* set pin 5 of PORTB for output*/
 DDRB |= _BV(DDB5);

 while(1) {
  /* set pin 5 high to turn led on */
  PORTB |= _BV(PORTB5);
  _delay_ms(BLINK_DELAY_MS);

  /* set pin 5 low to turn led off */
  PORTB &= ~_BV(PORTB5);
  _delay_ms(BLINK_DELAY_MS);
 }

 return 0;
}

Next Tip & Trick

Leave a Reply

You must be logged in to post a comment.