if (mode == 0) 
    { 
        // Turn motor at muscle flex & Turn back motor at muscle release  
        if (result >= 25 && sent_1 == 0) 
        {   
            //Send Character '1' over UART to SLAVE MCU to turn motor Clockwise  
            printf("1"); 

            //Set and Reset flags   
            sent_1 = 1;  
            sent_0 = 0;  
        } 
        else if (result < 25 && sent_0 == 0)
        { 
            //Send Character '0' over UART to SLAVE MCU to turn motor Counter-Clockwise  
            printf("0"); 

            //Set and Reset flags  
            sent_0 = 1;  
            sent_1 = 0;  
        }  
    } 

    else //Mode 1  
    { 
        // Turn motor at Muscle flex & Turn back motor at next muscle flex  
        if (result >= 25 && flex_flag == 0) 
        {  
            flex_flag = 1;

            if (motor_started == 1) 
            {  
                motor_started = 0;  
                printf("0");  
            } 

            else 
            {  
                motor_started = 1;  
                printf("1");  
            }  
        } 

        else if (result < 25 && flex_flag == 1) 
        {  
            flex_flag = 0;  
        }  
    }