Facebook
From kamil, 6 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 231
  1. #include <avr/io.h>
  2. #include <util/delay.h>
  3.  
  4. int main(void)
  5. {
  6.  DDRB |= (1 << PORTB7); // PORTB7 direction = out
  7.  
  8.  while (1)
  9.  {
  10.  
  11.   // 1 pulse
  12.   PORTB |= (1 << PORTB7); // PORTB7 hi = LED L on
  13.   _delay_ms(500); // 0.5 sec
  14.   PORTB &= ~(1 << PORTB7); // PORTB7 hi = LED L off
  15.  
  16.   // delay
  17.   _delay_ms(2000); // 2 sec
  18.  
  19.   // 2 pulses
  20.   PORTB |= (1 << PORTB7);
  21.   _delay_ms(500);
  22.   PORTB &= ~(1 << PORTB7);
  23.   _delay_ms(500);
  24.   PORTB |= (1 << PORTB7);
  25.   _delay_ms(500);
  26.   PORTB &= ~(1 << PORTB7);
  27.  
  28.   // delay
  29.   _delay_ms(2000);
  30.  }
  31. }