Sreejith K K
User Experience Designer











								

RobotC-code:

#pragma config(Sensor, S1, touchSensor, sensorTouch)
#pragma config(Sensor, S3, lightSensor, sensorLightActive)
#pragma config(Sensor, S4, sonarSensor, sensorSONAR)

int B = 25;          
int C = 25;           
int section = 1310;
task main()
{
  
  while(SensorValue[lightSensor] < 60) 
  {
    motor[motorB] = 20;                 
    motor[motorC] = 20;               
    
    if(SensorValue[sonarSensor] > 20)          
    {
    motor[motorB] = 18;                        
    motor[motorC] = 20;                      
    }
   
 if(SensorValue[sonarSensor] < 10)          
    {
    motor[motorB] = 20;                    
    motor[motorC] = 18;                   
    }                                    

  if(SensorValue(touchSensor) == 1)
  {
    nMotorEncoder[motorB] = 0;            
    while(nMotorEncoder[motorB] > (-85))  
    {
      motor[motorB] = -25;               
      motor[motorC] = -25;
    }

   
    nMotorEncoder[motorB] = 0;          
    while(nMotorEncoder[motorB] < 170)  
    {
      motor[motorB] = 25;              
      motor[motorC] = -25;            
    }
  } 
}