NXT light sensor to follow line

48 views
Skip to first unread message

Patrícia Carvalhais

unread,
Feb 8, 2024, 3:53:47 AM2/8/24
to Open Roberta
Hello everybody,
I'm trying to make a line follower lego NXT robot with a light sensor, but I'm having trouble as it doesn't follow the black line.
This is the code I'm using.
What could be wrong?NXT_line.PNG

Jörg Zieren

unread,
Feb 8, 2024, 4:11:40 AM2/8/24
to Patrícia Carvalhais, Open Roberta
An easy way to follow a colored line is to follow its edge (the line has to be wide enough for that - normal sticky tape width is OK). You take note of the sensor readings on the line, off the line, and halfway on/off. Then you turn, say, left when on the line, right when off the line, and go forward otherwise (which should be the halfway case). That should work with a black line too. It's easier than following the middle of the line because when you do that, and you lose the line, you don't know which way to turn to find it again.

I wonder, though, what kind of sensor "ambient light" is - it sounds wrong. In the sim there is a "colour sensor" that works.

-Jörg

--
You received this message because you are subscribed to the Google Groups "Open Roberta" group.
To unsubscribe from this group and stop receiving emails from it, send an email to open-roberta...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/open-roberta/4833aa84-441e-4280-9574-28cd2f2b605cn%40googlegroups.com.

Patrícia Carvalhais

unread,
Feb 8, 2024, 4:30:09 AM2/8/24
to Open Roberta
Hello everybody,
I don't have a color sensor, just a light sensor.
I've also noticed that it doesn't work in the simulator, but I wanted it to work in the physical robot.
light sensor.jpg

google

unread,
Feb 8, 2024, 4:47:16 AM2/8/24
to open-r...@googlegroups.com

You have to use "light" instead of "ambient light".

lightbutton.jpg

Patrícia Carvalhais

unread,
Feb 8, 2024, 5:32:20 AM2/8/24
to Open Roberta
I'll try this and let you know if it works!
Reply all
Reply to author
Forward
0 new messages