////mohamad saberian///
#include <mega8.h>  
#include  <delay.h>
unsigned int a;
unsigned int b ;
unsigned int c  ;
unsigned int d   ;
unsigned int e    ;
unsigned int f     ;

{



while(!(TCNT1&a));
     PORTB.0=1;
     delay_us(100);
     PORTB.0=0;
while(!(TCNT1&d));
     PORTB.1=1;
         delay_us(100);
    PORTB.1=0;
while(!(TCNT1&b));
     PORTB.2=1 ;
     delay_us(100);
     PORTB.2=0;
while(!(TCNT1&e));
     PORTB.3=1 ;
     delay_us(100);
     PORTB.3=0;
while(!(TCNT1&c));
     PORTB.4=1 ;
     delay_us(100);
     PORTB.4=0;
while(!(TCNT1&f));
     PORTB.5=1 ;
  delay_us(100);
     PORTB.5=0; 
     while(!(TCNT1&0Xbb8));
          TCCR1A=0x00;
          TCCR1B=0x00;
          TCNT1=0X00;
}

#include <delay.h>

#define ADC_VREF_TYPE 0xC0

// Read the AD conversion result
unsigned int read_adc(unsigned char adc_input)
{
ADMUX=adc_input | (ADC_VREF_TYPE & 0xff);
// Delay needed for the stabilization of the ADC input voltage
delay_us(10);
// Start the AD conversion
ADCSRA|=0x40;
// Wait for the AD conversion to complete
while ((ADCSRA & 0x10)==0);
ADCSRA|=0x10;
return ADCW;
}

// Declare your global variables here

void main(void)
{
unsigned int k;    
unsigned char n     ;

// Declare your local variables here

PORTB=0x00;
DDRB=0xFF;
PORTC=0x00;
DDRC=0x00;
PORTD=0x00;
DDRD=0x00;
   TCCR1A=0x00;
          TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
ACSR=0x0B;
SFIOR=0x00;
ADMUX=ADC_VREF_TYPE & 0xff;
ADCSRA=0x83;

// Global enable interrupts


while (1)
      {
      // Place your code here
      n=read_adc(0);
      k=(4.08*n)+2029;
      a=k;
      b=k+655;
      c=k+662;
      d=k+512;
      e=k+1350;
      f=K+2175;
      #asm("sei")   
      while(!(ACSR.5));
   
      }
    }