Advertisement
Guest User

Untitled

a guest
Jul 5th, 2012
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.51 KB | None | 0 0
  1. #include <avr/io.h>
  2. #include <util/delay.h>
  3.  
  4. void init(void); // Initiate io pins
  5. void ledh(void); // Led high
  6. void ledl(void); // Led low
  7.  
  8. int main(void)
  9. {
  10.     init();
  11.    
  12.     while (1)
  13.     {
  14.         if (bit_is_clear(PINC, 5))
  15.         {
  16.             for (int i=0; i<3;i++)
  17.             {
  18.             if (i > 0)
  19.                 _delay_ms(500);
  20.                 ledh();
  21.                 _delay_ms(500);
  22.                 ledl();
  23.             }
  24.         }
  25.     }
  26. }
  27.  
  28. void init (void)
  29. {
  30.     DDRC = 0b11011111;
  31.     PORTC = 0b00100000;
  32. }
  33.  
  34. void ledh(void)
  35. {
  36.     PORTC |= _BV(PC4);
  37. }
  38.  
  39. void ledl(void)
  40. {
  41.     PORTC &= ~_BV(PC4);
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement