Coach needs some help...

I'm not that experienced on RoboLab - I received the following request from Jim C. and am hoping some of our readers might be able to offer some suggestions:

"I am teaching a group of students immgrating from the RCX to NXT. We have been working on buidling a line follower using the NXT set.

We have decided to use the robolab 2.9 program to work on this project as they are more familiar with robolab software.

Would appreciate it if you could help to point us in the right direction with regards to the following:

1) How do I calibrate the NXT light sensors? I understand that the NXT-G software has a calibration function but not the robolab 2.9 software. There is no calibration file in the NXT brick as well so we can't use that.

2) Can 2 NXT light sensors be used to build a line follower robot? How different would the program be via-a vis using a single light sensor?

Thanks for the help."


Brian Davis said…
> How do I calibrate the NXT light sensors?

Why do you need to? The light sensor returns a value: all the NXT-G calibration does is select two numbers to scale that value between, so that the sensor returns 0 to 100 over a certain specified (calibrated) range of the raw return from the sensor. You could certainly do this under Robolab 2.9, it's just not built in. short version: the light sensor works JUST FINE without any special calibration.

> Can 2 NXT light sensors be used to
> build a line follower robot?

Certainly. And yes, the possibilities of using two light sensors are significantly different than with just one. How do you follow a line with one light sensor? Can you (or better yet, your students) think of a way to use two light sensors? A way similar to the one light sensor solution? How about completely novel ways?

Yes, I could stop being cryptic and just "give you an answer" here, but this is a fantastic chance to get the students to teach themselves. I'd encorage you to treat it that way.

Brian Davis
Robolab29 said…
>The light sensor works JUST FINE without any special calibration.

But then wouldn't the value need to be hardcoded thus making it operate incorrectly under different conditions?
Anonymous said…
Grab a copy of 'Engineering with LEGO Bricks and ROBOLAB' by Eric Wang from

This book is like the bible for RoboLAB
Brian Davis said…
> wouldn't the value need to be hardcoded...?

Not at all. The first thing the program could do is "request" the user to hold it over a white area and a black area, and use those to compute what the "correct" raw limits are, and use those in the program. Don't like that? Then write a seperate program that does this "calibration", and write those values to a file... which your line following program can read and use later. This, after all, is all the light sensor calibration really is - an auotmation of a technique that's been used by a lot of folks for a long time.

As to the book, does it cover Robolab 2.9 on the NXT?

Brian Davis
Anonymous said…
Eric Wang's current book doesn't address the NXT but the 3rd edition will and it looks like there's some other stuff NXT in the works at College House.

Engineering with LEGO bricks
and Robolab (3rd Edition)


Physics by Design (2nd Edition)
ROBOLAB Activities for the NXT and RCX
Anonymous said…
nxt-g would be the better software to choose because once you do get used to it, it becomes much easier to calibrate the sensors. but otherwise;

for the light sensors, the best way to use a single light sensor in my opinion (easiest, plus helps build simple math logic) is by using 3 values, 1. the value of the black line (middle of it) 2. the medium value of the edge of the line 3. the value of the white area.

so its a matter of light sensor hits white (assuming you start on the left side of the line) u turned to far left, so keep turning right untill you get to the medium value.

if you hit the low/dark value, then you turned to far right, move left.

play around with this, make it go forward or just keep bouncing back and forth between two values (slow but very accurate)

TWO light sensors: so much more fun and so much easier. a tank bot would work best (for turning).

simply "sandwich" the line by putting two light sensors at least a centimeter from the edges of the line. you can either have each light sensor control one side of the bot (simple program, i think the brick was called task split or something split) or make a more complicated program.

two light sensors would work extremly better, and iv been able to test it on complicated courses with sharp turns and gaps, easier to program, more fun too.

single light sensor works just fine one the circular track provided by lego.

and if you get the light values perfectly, u can do complicated tracks. the only problem with that is depending where the robo is facing, the light values will be different (angle, shadow, people blocking light, etc) so it becomes much harder to use 3 different values.

sorry if none of this made sense, no sleep can kill ya after a time.
Anonymous said…
Our FLL team used RoboLab 2.9 and managed to calibrate the NXT light sensors. But I'm not sure if it is the way you are talking about. We had the robot drive to the stain resistant fabric mission. On the way, it sees both and white. We had it store the highest and lowest values it saw and set them up as dark and light. I'm not sure because I didn't work on that program at all, but I believe that we manually set the "envelope" or where id decided if something was light or dark. And if it saw something lighter or darker than the first values, it would automatically set them up as the new high or low.
Anonymous said…
Did the format for leaving a comment just change? It's different than when I last posted (today)...
Anonymous said…
Gah! Now I know something is wrong...the list of contributers is down to two people! What happened, does this have something to do with Blogger switching out of Beta? I saw a notice for that...
Anonymous said…
hi im trying to build a light sensor robot but i cant find alink to help me please can you help me
Anonymous said…
hi im trying to make a robot with a light sensor but it dosent work can you help me
Anonymous said…
I have successfully programed my robot to follow a line using a single light sensor and am trying to develop a 2 light sensor version.

I have written a program that is marginally working but am having trouble with light shadows and inconsistent response. The robot moves foward 2 seconds and reads each each light sensor . If left sensor reads black then robot turns left until it sees white. If right sensor reads back then it turns right until it sees white. Then it repeats the process. does anyone have any hints?

Popular Posts