View unanswered posts | View active topics It is currently Sun Dec 08, 2019 10:11 am






Reply to topic  [ 10 posts ] 
Help with color sensor and move robot until black line 
Author Message
Rookie

Joined: Wed May 06, 2015 2:40 pm
Posts: 7
Post Help with color sensor and move robot until black line
Hi - I have no problem with light sensor and moving robots. However, I am trying to use color sensor. I am able to get color reading but I tried to move robot (example: move to black line then stop)

I have look up FAQ and instruction but to no avil. Can anyone give me simple program where it will command robot to move until it reach black duct tape then stop or move backward?

I followed someone's program here:

task main()
( string sColor; while (true) (switch (SensorValue[colorport])

{

case 1: sColor = "Black"; break:
case 2 sColor = "Black"; break:
case 3: sColor = "Black"; break:
case 4: sColor = "Black"; break:
case 5: sColor = "Black"; break:
case 6: sColor = "Black"; break:

}

nxt Displaycenteredtextline(2, sColor);
wait1Msec(50);
}

But where do I input command to tell robot to move until black line??

Thank you.


Wed May 06, 2015 3:05 pm
Profile
Rookie

Joined: Wed May 06, 2015 2:40 pm
Posts: 7
Post Re: Help with color sensor and move robot until black line
By the way, I am using nxt controller and color sensor from legominstorm. Not Evo but older version.

Program I use is Robotc for Lego Mindstorm S


Wed May 06, 2015 3:07 pm
Profile
Rookie

Joined: Wed May 06, 2015 2:40 pm
Posts: 7
Post Re: Help with color sensor and move robot until black line
Anyone else?


Thu May 07, 2015 9:13 am
Profile
Rookie

Joined: Wed May 06, 2015 2:40 pm
Posts: 7
Post Re: Help with color sensor and move robot until black line
BUMP -

Do not anyone here know how to program robot to move and stop at black line using color sensor?


Thu May 14, 2015 1:22 pm
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 722
Post Re: Help with color sensor and move robot until black line
There is a section in the ROBOTC Graphical Introduction to Programming EV3 Curriculum (link below) that actually deals with this specific scenario. The section you will want to review is the "Forward Until Color" section under the 'Sensors' part of the Curriculum.

ROBOTC Graphical Introduction to Programming EV3 Curriculum: http://www.education.rec.ri.cmu.edu/pre ... urriculum/

Please take a look through the curriculum and go through each of the segments step by step, as they should guide you in solving this particular problem. Let us know if you run into any issues as we are always happy to help!

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our updated help documentation and the ROBOTC Forums.


Thu May 14, 2015 5:19 pm
Profile
Rookie

Joined: Wed May 06, 2015 2:40 pm
Posts: 7
Post Re: Help with color sensor and move robot until black line
Hi Jason - I am using NXT legomindstorm so I dont have EV3. Here's what I am talking about http://www.education.rec.ri.cmu.edu/pre ... x_preview/

There's instruction for light but none for color sensors.


Tue May 26, 2015 11:06 am
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 722
Post Re: Help with color sensor and move robot until black line
I apologize for the confusion; there is a relevant section for the light sensor, "Forward Until Dark" (found under the 'Sensing' section), for the NXT light sensor that can be found in the ROBOTC Curriculum for TETRIX and LEGO MINDSTORMS (link below). You can use this lesson and programming logic with the color sensor instead; you will need to look for a color value (possible colors are below) instead of a threshold value, and check to see if the color sensor is equal to a value, not less than/greater than.

Code:
 BLACKCOLOR
     BLUECOLOR
     GREENCOLOR
     YELLOWCOLOR
     REDCOLOR
     WHITECOLOR


ROBOTC Curriculum for TETRIX and LEGO MINDSTORMS: http://www.education.rec.ri.cmu.edu/pre ... index.html

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our updated help documentation and the ROBOTC Forums.


Tue May 26, 2015 1:01 pm
Profile
Rookie

Joined: Wed May 06, 2015 2:40 pm
Posts: 7
Post Re: Help with color sensor and move robot until black line
Great! Thanks! I managed to get color sensors to behave like light sensors.

But... my next challenge is to get robot to read colors and move along color line. Is it very complicate/difficult to do?


Wed May 27, 2015 3:40 pm
Profile
Rookie

Joined: Wed May 06, 2015 2:40 pm
Posts: 7
Post Re: Help with color sensor and move robot until black line
I am trying to limit bot to inside black ring on white paper but it will not move at all. I am using legomindstorm's poster whEre there's black ring and several color block on it. Can you correct my coding? Thanks.

black is 1 and white is 6.


task main()

{

while(SensorValue(colorport) < BLACKCOLOR)
{
motor[motorB]=50;
motor[motorC]=50;


}

motor[motorB]=0;
motor[motorC]=0;
wait1Msec(1000);

}


Wed May 27, 2015 5:05 pm
Profile
Expert

Joined: Thu Dec 01, 2011 12:07 am
Posts: 151
Post Re: Help with color sensor and move robot until black line
You should explain in English detailed to the sensor and motor level what you want the program to do before writing code. This will help you actually understand what you want to do and help others to help you.


Wed May 27, 2015 10:19 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 10 posts ] 

Who is online

Users browsing this forum: No registered users 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.