title: How to delay a output about 15 minutes after pressing a button?
body: <p>I am learning micro controller programming. I need help to complete my program at WinAVR with Atmega8L-8PU. 
  i have added 3 buttons, when the buttons pressed: first button will supply output for 15 minutes, 2nd one will 30 minutes and the last 3rd one will 45 minutes. after elapsing each time that should auto reset for the next press.</p>
  
  <p>Here is my codes i have wrote but i cant added time duration. if anybody can make it it will be very helpful for me. Advance Thanks :).</p>
  
  <pre><code>#define numberofButtons 3
  
  #include &lt;avr/io.h&gt;
  #include"buttonpress.h"
  
  int main(void)
  {
  
      DDRB = 0b00000000;
      DDRD = 0b00000111;
      PORTB = (1&lt;&lt;PINB0)|(1&lt;&lt;PINB1)|(1&lt;&lt;PINB2);
  
      while(1)
      {
          if (buttonpressed(0, PINB, 0, 100))
          {
              PORTD ^= (1&lt;&lt;PIND0);
          }
  
          if (buttonpressed(1, PINB, 1, 100))
          {
              PORTD ^= (1&lt;&lt;PIND1);
          }
          if (buttonpressed(2, PINB, 2, 100))
          {
              PORTD ^= (1&lt;&lt;PIND2);
          }
      }
  }
  </code></pre>
  
  <p>i have tried this way but it also not working........ :(</p>
  
  <pre><code>#define numberofButtons 3
  
  #include"buttonpress.h"
  #include &lt;avr/io.h&gt;
  #include &lt;avr/interrupt.h&gt;
  
  unsigned char seconds =0;
  int minutes;
  
  int main () 
  { 
      DDRB = 0b00000000;
      DDRD = 0b00000111; 
      PORTB = (1&lt;&lt;PINB0)|(1&lt;&lt;PINB1)|(1&lt;&lt;PINB2);
  
      volatile int seconds;
      DDRD |= (1&lt;&lt;PIND0)|(1&lt;&lt;PIND1)|(1&lt;&lt;PIND2);
      TCCR1B |= (1 &lt;&lt; WGM12);                     // Configure timer 1 for CTC mode 
      TIMSK |= (1 &lt;&lt; OCIE1A);                     // Enable CTC interrupt
  
      sei();                                      // Enable global interrupts
      OCR1A = 15624;                              // Set CTC compare value to   1Hz at 8MHz AVR clock, with a prescaler of 64 
      TCCR1B |= ((1 &lt;&lt; CS10) | (1 &lt;&lt; CS11));  // Start timer at Fcpu/64
  
      while (1) 
      { 
  
          if(seconds==60) 
          { 
              minutes++;
              seconds=0;
          }
          {
              if (buttonpressed(0, PINB, 0, 100))
              { 
                   PORTD ^= (1&lt;&lt;PIND0);
                   int total_seconds=900;
  
                   while(total_seconds-seconds!=0) 
                   { 
                       //Delay of 15 min 
                   } 
               }
  
            } return 0; 
        }
     }
  
   ISR (TIMER1_COMPA_vect)
   {
      seconds++;
   }
  </code></pre>