#include <mega16.h> 
#include <delay.h> 
// Declare your global variables here 
 
void main(void) 
{ 
// Declare your local variables here 
 
// Input/Output Ports initialization 
// Port A initialization 
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In  
// State7=T State6=T State5=T State4=T State3=T State2=T State1=P State0=P  
PORTA=0x03; 
DDRA=0x00; 
 
// Port B initialization 
// Func7=In Func6=In Func5=In Func4=In Func3=Out Func2=In Func1=In Func0=In  
// State7=T State6=T State5=T State4=T State3=0 State2=T State1=T State0=T  
PORTB=0x00; 
DDRB=0x08; 
 
  while (i<bright)
		{
		OCR1B=i;
		_delay_ms(10);
		i++;
		}
 
// Port D initialization 
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In  
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T  
PORTD=0x00; 
DDRD=0x00; 
 
// Timer/Counter 0 initialization 
// Clock source: System Clock 
// Clock value: 125,000 kHz 
// Mode: Fast PWM top=FFh 
// OC0 output: Non-Inverted PWM 
TCCR0=0x6B; 
TCNT0=0x00; 
OCR0=0x00; 
 
while (1) 
  { 
  // Place your code here 
  if((PINA.0==0)&(OCR0!=0xff)) //      
  { 
  delay_ms(10); //  10 . 
  OCR0+=1; //  
  } 
  if((PINA.1==0)&(OCR0!=0x00)) //      
  { 
  delay_ms(10); //  10 . 
  OCR0-=1; //  
  } 
    
 }; 
    
}

eeprom unsigned int *wheele_set; 
eeprom unsigned char *cilinders_set;

*wheele_set=170;
*cilinders_set=4;

wheele=*wheele_set;
cilinders=*cilinders_set;


unsigned char EEPROM_read(unsigned int uiAddress)
{
/* Wait for completion of previous write */
while(EECR & (1<<EEWE))
;
/* Set up address register */
EEAR = uiAddress;
/* Start eeprom read by writing EERE */
EECR |= (1<<EERE);
/* Return data from data register */
return EEDR;
}
 
void EEPROM_write(unsigned int uiAddress, unsigned char ucData)
{
/* Wait for completion of previous write */
while(EECR & (1<<EEWE))
;
/* Set up address and data registers */
EEAR = uiAddress;
EEDR = ucData;
/* Write logical one to EEMWE */
EECR |= (1<<EEMWE);
/* Start eeprom write by setting EEWE */
EECR |= (1<<EEWE);
}


flash char f[]="This is a test";
#pragma warn-
eeprom char e[16];
#pragma warn+
char r[16];

void main (void)
{
char flash *ptr_to_flash;
char eeprom *ptr_to_eeprom;
char *ptr_to_ram;

// copy the string f from FLASH to
// the string e in EEPROM
ptr_to_flash=f;
ptr_to_eeprom=e;
while (*ptr_to_flash)
      *ptr_to_eeprom++=*ptr_to_flash++;
// NULL terminate the string in EEPROM
*ptr_to_eeprom=0;

// copy the string e from EEPROM to
// the string r in RAM
ptr_to_eeprom=e;
ptr_to_ram=r;
while (*ptr_to_eeprom)
      *ptr_to_ram++=*ptr_to_eeprom++;
// NULL terminate the string in RAM
*ptr_to_ram=0;

// stop here
while (1);
}

    { 
      for (((R=0)&&(G=0)&&(B=0));((R<tempR)&&(G<tempG)&&(B<tempB));((R+=r2/17)&&(G+=g2/17)&&(B+=b2/17)))
      delay_ms(10);
    }
    
    