Okay so I'm in a rut here, I have to do a project for an entry level engineering class andmy final in the class is to program an NXT robot to follow a line and based on the color of the lineit will display what color the line is, in my head the program sounds easy but when I think about actually trying to write the code I just cannot figure it out. I know this is kind of a huge request but can someone either get me going in the right direction I.E. Write the code for one color, lets say blue.and then I could finish the rest or just give me huge hints, I'm really stuck and this is stressing me out.I cannot use a color sensor, I have to use a light sensor for this project as my class does not have access to color sensors and I have the values of the colors I'm supposed to use. * Blue = 21 * Red = 57 * Green = 47 * Yellow = 60 * Orange = 53Sorry if this post sounded whiny or rude, I'm just really frustrated and would appreciate some help. Thanksin advance for any help or advice.

Okay so I'm in a rut here, I have to do a project for an entry level engineering class andmy final in the class is to program an NXT robot to follow a line and based on the color of the lineit will display what color the line is, in my head the program sounds easy but when I think about actually trying to write the code I just cannot figure it out. I know this is kind of a huge request but can someone either get me going in the right direction I.E. Write the code for one color, lets say blue.and then I could finish the rest or just give me huge hints, I'm really stuck and this is stressing me out.I cannot use a color sensor, I have to use a light sensor for this project as my class does not have access to color sensors and I have the values of the colors I'm supposed to use. * Blue = 21 * Red = 57 * Green = 47 * Yellow = 60 * Orange = 53Sorry if this post sounded whiny or rude, I'm just really frustrated and would appreciate some help. Thanksin advance for any help or advice.

What color is the backround? Unless it's really bright or really dark, I'm not sure that this would work. Could you post a pic of the track, or a drawing, or similar? Some of the values you list are very close(some identical)to the average values for black and white surfaces.

_________________A.K.A. inxt-generationSelf-proclaimed genius, and future world dominator.My Brickshelf Folder"Don't they teach recreational mathematics anymore?" - The Tenth DoctorBow down to Nikola Tesla, King of the Geek Gods.

Mon Apr 02, 2012 1:25 pm

Squidgy

Rookie

Joined: Mon Apr 02, 2012 12:18 pmPosts: 4

Re: Light Sensor dector, + line following.

The background is white and the track is just like a decently big sized piece of paper different parts of the oval being the different colors, I.E.blue, orange, yellow, etc.

The background is white and the track is just like a decently big sized piece of paper different parts of the oval being the different colors, I.E.blue, orange, yellow, etc.

That sounds simple enough. Have you tested to make sure that there is at least a 5 percent difference between the backround and the line at all times? If there isn't enough contrast between the line and the backround, the robot might not see the line and then you could get some peculiar behavior. If the robot can't distinguish the line from the backround at some point, it would require a significantly different algorithm the if it could see at all times. Also, how many sensors is it using to "see" the line?

_________________A.K.A. inxt-generationSelf-proclaimed genius, and future world dominator.My Brickshelf Folder"Don't they teach recreational mathematics anymore?" - The Tenth DoctorBow down to Nikola Tesla, King of the Geek Gods.

Mon Apr 02, 2012 4:49 pm

Squidgy

Rookie

Joined: Mon Apr 02, 2012 12:18 pmPosts: 4

Re: Light Sensor dector, + line following.

All we are allowed to use is one NXT Light Sensor. :/We first tried programming it in the LEGO MindStorms program but found itto be very confusing for this task. and yes there is a 5% difference sono worries about that.

I apoligize for the delay in response, I was really busy this past week. I've got an idea, but have you made any progress yet?

_________________A.K.A. inxt-generationSelf-proclaimed genius, and future world dominator.My Brickshelf Folder"Don't they teach recreational mathematics anymore?" - The Tenth DoctorBow down to Nikola Tesla, King of the Geek Gods.

Wed Apr 11, 2012 12:54 pm

Squidgy

Rookie

Joined: Mon Apr 02, 2012 12:18 pmPosts: 4

Re: Light Sensor dector, + line following.

I have made no progress due to people in my family becoming hospitalized,but anyways; what's your idea?

My idea is this: I think that you would want to use a simple line-following algorithm, yes? If so, then you would be turning one direction when on the line, and the other when off. So you would want to do something like this: BTW, this is written in suedo-code. If you put this in the editor, it will not actually work.

Code:

while(true)//loop forever{ if(sensor doesn't see the line) { do whatever to get back on the line } else { do whatever to turn away from the line

Now here's the bit your having trouble with. It's actually pretty simple, if you know what to do. if(SensorValue(LightSens) >= lowercolorval && SensorValue(LightSens) <= uppercolorval) { Display name of color; } repeat for each color there is. }}

So, basically, it's a simple bang-bang line follower, that checks the reflection when it's on the line and compares it with known values to determine the color of the line, and then display it. Have I explained it well enough?

_________________A.K.A. inxt-generationSelf-proclaimed genius, and future world dominator.My Brickshelf Folder"Don't they teach recreational mathematics anymore?" - The Tenth DoctorBow down to Nikola Tesla, King of the Geek Gods.

Who is online

Users browsing this forum: No registered users and 2 guests

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