How could i use lejos for legos mindstorms to use a colorlight sensor to follow a straight black line?
Hi Josh,
[01] I couldn’t find technical information about your color sensor (a link to a datasheet would be helpful), so I will assume that it works on the same principles as most of the hobby color sensors.
[02] Typically, robots that are designed to follow black line use two (2) optical sensors fixed some distance apart. Each sensor’s output is proportional to the amount of light which is reflected from under the sensor; line reflects less than the floor. When the robot is on the line, the sensors are located somewhat symmetrically on either side of the line, and their outputs are the same (or close). When the robot drifts off the line slightly, one sensor sees more line that other, the difference between their outputs increases, and the robot can take corrective action (e.g. turn to get back on the line).
[03] The method described in [02] typically uses IR LED(s) and photodiodes or prototransistors. But it could be done with two (2) color sensor as well.
[04] You could use a single color sensor, if you can modify the design of your line, and have blue and red lines running next to each other. When the robot deviates from the line, the color sensor would see increase in either red or blue.
Hope it helps!
- Nick
Currently Available on eBay
![]() |
![]() LEGOS - MINDSTORMS 9V MOTOR WITH SENSOR AND CONNECTORS £18.83
|
![]() LEGO Technic Mindstorms ultrasonic sensor £1.00
|
![]() LEGO Mindstorms Sound Sensor 9845 BRAND NEW Sealed £19.99
|
![]() LEGO® MINDSTORMS® NXT Touch Sensor Fast Dispatch £8.99
|
![]() LEGOS - MINDSTORMS 9V MOTOR WITH SENSOR AND CONNECTORS £18.83
|
![]() Lego Mindstorm 8527/8547 2.0 NXT Touch Sensor 53793 £7.95
|
![]() LEGO Technic Mindstorms 9V Electric Touch Sensor Brick 3 x 2 - 879 £3.49
|
![]() Gyroscopic Sensor for LEGO® MINDSTORMS® NXT Gyro Sensor for LEGO NXT Robot £37.20
|
![]() Infrared Seeking Sensor for LEGO® MINDSTORMS® NXT IR Seeker for LEGO NXT Robot £37.20
|
![]() Lego Mindstorms NXT 2.0 Software, Color Sensor and Color Sphere Balls 8547 New £46.20
|
And a selection of products from Amazon
![]() |
Compass Sensor for MINDSTORMS® NXT
Sale Price: £59.95 |
DescriptionMeasures the earth's magnetic field and outputs a value representing the current heading |
![]() |
LEGO 8547 Mindstorms NXT 2.0 Robot
Sale Price: £289.00 |
![]() |
Lego MindStorms Temp Sensor ITEM 9889
Sale Price: £7.99 |
![]() |
Core Lego Mindstorms: Programming the RCX in Java
List Price: |
Testing the Mindstorms NXT Laser Target Sensor


£18.83













