/*
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    program name : sensor.ic
    description  : program for learning the functionality of handy board sensor
    done by      : Team 9    
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*/

/* PROGRAM CONSTANTS */
#define POWER_FULL        100              
#define MOTOR_LEFT        0
#define MOTOR_RIGHT       2

#define SENSOR_LEFT    10 
#define SENSOR_RIGHT   15

#define TRUE           1
#define FALSE          0

/*
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    functio name : sensor.ic
    description  : rotates the robot about its right wheel as axis by giving 
                   full power to the other wheel.
    done by      : Team 9    
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*/

void rotate()
{
    motor(MOTOR_LEFT,POWER_FULL);
    
}
void main()
{
    
    /*
       when one of its touch sensors is triggered, it will start
       rotating around itself until the same touch sensor is triggered 
       for the second time

    */
    int firstTime = TRUE ; 
    while(TRUE) 
      {
        // First sensor touched , so rotate and print "First"
        if (digital(SENSOR_RIGHT) && firstTime ) 
          {
            rotate();
            firstTime = FALSE ;
            printf("First");
        }
        // Sensor touched again , turn off the motor and print 
        // "Second"
        if ( digital(SENSOR_RIGHT) && firstTime == 0 )
          {
            firstTime = TRUE ; 
            off(MOTOR_LEFT); 
            printf("Second"); 
        }
        
    }
    
}
