provide-free-support Ujjwal's Blog: blink.c
Showing posts with label blink.c. Show all posts
Showing posts with label blink.c. Show all posts

Thursday, February 28, 2013

My first AVR LED Blink program in C

Hi,

I recieved my AVR programmer device last week so, i wrote my first LED blinking program in C (AVR). I used ATMEGA328P-PU chip. Earlier i have assembled my own arduino board so i used the same board for AVR by erasing the bootloader. below is my code

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

/*
  @author Ujjwal Soni
  Connect a LED between pin 13 and GND.
 */


void delay()
{
  unsigned char counter = 0;
  while (counter != 50)
  {
    /* wait (30000 x 4) cycles = wait 120000 cycles */
    _delay_loop_2(30000);
    counter++;
  }
}


int main(void)
{
  /* Initialization, set PB5 (arduino digital pin 13) as output */
  DDRB |= (1<<PB5);

  while (1) 
  {
    PORTB |= (1<<PB5);  //arduino digital pin 5 -> 5V
    delay();
    PORTB &= ~(1<<PB5);  //arduino digital pin 5 -> GND   
    delay();
  }
  return 0;
} 

Please note that my LED is connected on PIN13.  
I will be also writing pushbutton code which i will be posting here soon.

Cheers,

Ujjwal Soni
best-it-exam-    | for-our-work-    | hottst-on-sale-    | it-sale-    | tast-dumps-us-    | test-king-number-    | pass-do-it-    | just-do-it-    | pass-with-us-    | passresults-everything-    | passtutor-our-dumps-    | realtests-us-exam-    | latest-update-source-for-    | cbtnuggets-sale-exam    | experts-revised-exam    | certguide-sale-exam    | test4-sale-exam    | get-well-prepared-    | certkiller-sale-exam    | buy-discount-dumps    | how-to-get-prepared-for-the    | in-an-easy-way    | brain-dumps-sale    | with-pass-exam-guarantee    | accurate-study-material    | at-first-try    | 100%-successful-rate    | get-certification-easily    | material-provider-exam    | real-exam-practice    | with-pass-score-guarantee    | certification-material-provider    | for-certification-professionals    | get-your-certification-successfully    | 100%-Pass-Rate    | in-pdf-file    | practice-exam-for    | it-study-guides    | study-material-sku    | study-guide-pdf    | prep-guide-demo    | certification-material-id    | actual-tests-demo    | brain-demos-test    | best-pdf-download    | our-certification-material    | best-practice-test    | leading-provider-on    | this-course-is-about    | the-most-reliable    | high-pass-rate-of    | high-pass-rate-demo    | recenty-updated-key    | only-for-students-free-download    | courseware-plus-kit-for    | accurate-answers-of    | the-most-reliable-id    | provide-training-for    | welcome-to-buy    | material-for-success-pass    | provide-free-support    | best-book-for-pass    | accuracy-of-the-answers    | pass-guarantee-id    | pass-exam-key    | pass-sku-id    | study-for-exid    | pdf-sku-exid    | sku-pdf-id    | pdf-demo-key    | exam-demo-ske    | pass-it-dump    |
http://www.menuiserie-dauvergne.com/    | http://www.menuiserie-dauvergne.com/    |