View unanswered posts | View active topics It is currently Thu Jul 31, 2014 11:35 am






Reply to topic  [ 3 posts ] 
Problems with my EV3 colour sensor 
Author Message
Rookie

Joined: Tue Jul 29, 2014 3:07 pm
Posts: 2
Post Problems with my EV3 colour sensor
I have to detect some colours with my EV3 colour sensor and it doesn't work as it is supposed. When I try the code debugging, it works fine, but when I try the code on the robot, without debugging it doesn't work. Is it one of the known issues to correct? And, will it work if I change put the NXT colour sensor instead of the EV3 colour sensor? (To change it I have to dismount a lot of things of my robot).
Otherwise, what am I doing wrong?

This is a simple code that works debugging but not when I run it on the robot
Code:
task main(){
setSensorMode(color, 2); //color is the name that I have given to the sensor
if (SensorValue(color)==6) //now it is detecting white
    base_180(); //it moves a motor 180 degrees
else
    base_90_AH();    //it moves a motor 90 degrees.
}


In this case, detecting always the same thing, if it is debugging, it moves a motor 180 degrees. Running it without debugging, does the 'else' case, it moves the motor just 90 degrees


Tue Jul 29, 2014 3:19 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3165
Location: Rotterdam, The Netherlands
Post Re: Problems with my EV3 colour sensor
You need some kind of while loop in there so that it doesn't run straight through.

Code:
task main(){
  setSensorMode(color, 2); //color is the name that I have given to the sensor
  while (true)
  {
    if (SensorValue[color]==6) //now it is detecting white
      base_180(); //it moves a motor 180 degrees
    else
      base_90_AH();    //it moves a motor 90 degrees.
  }
}


= Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Wed Jul 30, 2014 1:19 am
Profile WWW
Rookie

Joined: Tue Jul 29, 2014 3:07 pm
Posts: 2
Post Re: Problems with my EV3 colour sensor
Okay, thanks.
However, I have realised that it works as you have told me with that while loo, but that is not exactly what I want. In fact, I am trying to make a Rubik's cube solver, and I want to save the colors of the cube in an array. So, I don't understand why I need that while loop, because in the function "base_180()" I am using the "waituntilmotorstops" function, so it should do that and then continue with the next statement when the motor has stopped, in this case, however, nothing else.

Anyway, if I save the value of the colors of the cube in an array, will it save the values without any while loop or something like that?


Wed Jul 30, 2014 8:39 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: robotbambi and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.