// 

 

#include <io.h>

#include <delay.h>
#include <math.h>

#include <stdio.h>
#include <MEGA48.h>

#define FOSC 8000000UL // 
#define BAUD 9600
#define MYUBRR ((FOSC/(BAUD*16UL)) - 1)

unsigned char u_data=0, u_com=0;

interrupt [USART_RXC] void USART_RXC1(void)
    {   
       u_com=(unsigned char)UDR0;
        //            
       




    }
 
void USART_Init(unsigned int ubrr)
{
//
UBRR0H=(unsigned char) (ubrr>>8);
UBRR0L=(unsigned char) ubrr;
//   
UCSR0B= (1<<RXCIE0)|(1<<RXEN0)|(1<<TXEN0);
// -8, 1 
UCSR0C=(0<<USBS0)|(3<<UCSZ00);
}

void USART_Transmit(unsigned char data)
{
//   
while (!(UCSR0A & (1<<UDRE0)));
//   ,  
UDR0=data;
}


    
void main (void)
    {
    DDRD = 0b11111110;                // int0 - input rx - input
    PORTD = 0b00000001; 
    DDRC=0x03;
     PORTC=0x00;  //PC0,PC1 -  
     USART_Init(MYUBRR);
     delay_ms(1);
     #asm("sei");
            
     while(1){
      
            
      
       if (u_com==49) 
         {
         PORTC.0 = 1;
         PORTC.1 = 0;     
              
              } 
              
         else if (u_com==0) 
         {
         PORTC.0 = 1;
         PORTC.1 = 1;     
              
              }   
              
        else if (u_com==50){  
        PORTC.0 = 0;
        PORTC.1 = 1;  
             }

          
                
      
       } } 
      