Cooler_

Cooler`s AVR blink

Jul 3rd, 2012
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.51 KB | None | 0 0
  1. /*
  2. codando com gcc-avr
  3. pisca pisca simples no pino 5
  4.  
  5. by Cooler_
  6. c00f3r[at]gmail[dot]com
  7.  
  8. tudo isso para fazer led piscar :-/
  9.  
  10. */
  11.  
  12. #include <avr/io.h>
  13. #include <util/delay.h>
  14. #define LEDPIN 5
  15.  
  16. void
  17. pausa(unsigned int ms)
  18. {
  19.   unsigned int x,y;
  20.   for(y=0; y<1000; y++)
  21.     for(x=0; x<ms; x++);
  22. }
  23.  
  24. int
  25. main (void)
  26. {
  27.  
  28.  // para usar pino 5
  29.  DDRD|=1<<LEDPIN;
  30.  
  31.  do{
  32.   // OFF  
  33.   PORTD&=~(1<<LEDPIN);
  34.   pausa(500);
  35.  
  36.   // ON
  37.   PORTD|=1<<LEDPIN;
  38.   pausa(500);
  39.  }while(1);
  40.  
  41.   return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment