ROBOTC.net forums
http://www.robotc.net/forums/

how to use different mode of color sensor (Color/Reflected)
http://www.robotc.net/forums/viewtopic.php?f=1&t=13775
Page 1 of 1

Author:  denist [ Wed Mar 30, 2016 12:55 pm ]
Post subject:  how to use different mode of color sensor (Color/Reflected)

Hi,

i like to read the reflected Value and the color green.

Code:
#pragma config(Sensor, S2,     colorR,         sensorEV3_Color)
#pragma config(Sensor, S3,     colorL,         sensorEV3_Color)
#pragma config(Motor,  motorB,           ,             tmotorEV3_Large, PIDControl, reversed, driveRight, encoder)
#pragma config(Motor,  motorC,           ,             tmotorEV3_Large, PIDControl, reversed, driveLeft, encoder)


task main()
{
        float colorLeft ;
        float colorRight;

        float reflectedLeft;
        float reflectedRight;

while(true){
        setSensorMode(colorR,modeEV3Color_Color);
        setSensorMode(colorL,modeEV3Color_Color);
        sleep( ?? ); // ???? ####               #####  <=  ###[color=#FF0000] How much time do i need minimum?  [/color]###
        colorLeft  = SensorValue[colorL];
        colorRight = SensorValue[colorR];
       
        setSensorMode(colorR,modeEV3Color_Reflected);
        setSensorMode(colorL,modeEV3Color_Reflected);
       [color=#FF0000] sleep( ?? ); // ???? ####               #####[/color]
        reflectedLeft =SensorValue[colorL];
        reflectedRight =SensorValue[colorR];

       

       if(reflectedLeft >90){
        //stop motor B and C
       }else{
         //motor B and C on
     }
      if(colorLeft==3){ //green
       //go Left
      }
      if(colorRight ==3){ //green
       //go Right
      }
 }

}

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/