Primary Color:
Primary Text:
Secondary Color:
Secondary Text:
Tertiary Color:
Tertiary Text:
Color Picker
Preview
FeaturesTypographyTutorials
Module Title
Home
Module Title

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut non turpis a nisi pretium rutrum. Nullam congue, lectus a aliquam pretium, sem urna tempus justo, malesuada consequat nunc diam vel justo. In faucibus elit at purus. Suspendisse dapibus lorem. Curabitur luctus mauris.

Module Title
Module Title
Instructions

Select a predefined style from the drop-down or choose your own colors via the handy mooRainbow based color-chooser. When you are satisfied with your selection, click the "Apply Colors" button below to store your selection in a cookie.

Apply Colors

Search


Facebook_icon_64 Twitter-icon_64

Translate this page

Programming Light Sensors

Open as PDF Send to a friend Print Version
Comments (8)
Written by mc
13 Jul 2010
Add Article to Group
In this area we are going to post ideas about programming light sensor.NXT_Light_Sensor
Tags: NASA (2) , STEM (2) , robotics (2) , NASATalk (2) , LEGO (2)
Last update (06 Jun 2013)


Comments


0 + | -
Programming Light Sensors
Written by: James Nobles On: 22 Apr 2013

Yeah I need to program a light sensor to drive across red and black and at the same time it needs to say the colors as it drives.



0 + | -
Programming Light Sensors
Written by: mc On: 06 Jun 2013

Sorry I just saw this message, James. Are you still working on this challenge, or did you already solve it. 

If you solved it, would you share how you did it? If you still need help, please let me know. I'd say this starting by viewing the light sensor readings over the red and black lines so you know what numbers to include in your program.



2 + | -
Calibrating Light Sensors
Written by: Brian Woerner On: 09 Sep 2010

Hi Everyone!

One of the frustrations that beginners face in programming the light sensors is that the exact measurements from the light sensor changes depending on the environment.   For example, you may develop a program one afternoon to make the robot stop at a black line, by stopping when the light sensor reading is less than '45'.  However, when you run it later that night when the room is darker, the robot stops way before the black line is reached.   And when you run it on a sunny morning, the robot cruises on past the black line.   The same thing might happen when you program at home in your basement and then take it to a tournament in a well-lit auditorium.

What is happening here?   When we program the NXT, we use a scale of 0 (darkest) to 100 (brightest) to describe output of the light sensor, but that number is really a percentage.  The physical light sensor gives the robot brick a number from 0 to 1023.   In a very brightly lit room, the darkest reading may be 478 (47%) and the brightest reading may be 891 (87%).   In a very dimly lit room, the darkest reading may be 194  (19%) and the brightest reading might be 445  (43%).   You can verify this by viewing the light sensor output on your NXT robot screen under different conditions.   So if we use those raw percentage readings and set our threshold 45%, we may end up with a program that doesn't work in some environments.

Fortunately, NXT has a solution to this problem called "Calibration".    Calibrating the robot to a particle environment means that from then on, 0% will represent the darkest reading found in that environment (usually black), and 100% will represent the brightest reading in that environment (usually white).   Once you calibrate the robot, "0" will really mean 'black' and "100" will really mean "white".  By creating such a wide range between white and black, you can safely set your threshold to "50" in your programs and not worry about it anymore. 

The robot can be calibrated manually, but it is often convenient for FLL competitions to have a short program to calibrate your light sensor.   I've attached the example "Calibrate.rbt" to this post.   Basically, it just asks you to place the light sensor over a solid black region and take a reading, then place the light sensor over a solid white region to take a reading.   

You can run this program at the table before the round begins and the calibration settings will hold for all of your subsequent programs, until you clear the settings or turn the robot off.   My understanding is that in most FLL competitions, the judges do permit you to run a calibration routine before the round begins.

One other thing to note:  although the calibration routine says it is for a light sensor in port 3, it will also set the calibration for any other light sensors you plug into other ports.  

Good luck, and thanks to Meri & NASA for providing this great forum       

Attachment: 1284065380_Calibrate.rbt (Size: 782 Kb | Hits: 757)



1 + | -
Calibrating Light Sensors vs. Blocking Room Light
Written by: mc On: 24 Oct 2011

Great description, Brian! Cool

Attached is a jpg of your program for those who don't have the NXT software on their computers.

BLOCKING LIGHT SENSORS WORKS, TOO!

In addition to calibrating - if your room has consistent lighting - you can also BLOCK the light sensors - especially those positioned near the ground, so they see ONLY the light reflected from the sensor, and don't get a lot of interference from different levels of room light. Then shadows don't get in your way.

BUT, blocking won't work so well for sensors pointing sideways, looking for objects of different colors, when you can't completely close off the room light.

Attachment: 1319487695_Screen shot 2011-10-24 at 4.22.07 PM.png (Size: 103 Kb | Hits: 606)



8 + | -
Programming Light Sensors-Challenge 1-Forward until dark?
Written by: Jeff Rosen On: 12 Aug 2010
I will try to do so in a couple of weeks.  I am preparing for the opening of the next ePDN robotics offering in Sept. and the opening of the FLL compeititon season.


0 + | -
Programming Light Sensors-Challenge 1-Forward until dark?
Written by: Meri Cummings On: 12 Aug 2010

Thanks, Jeff. It's so easy to forget that pesky DURATION UNLIMITED setting!

Since you solved this challenge, would you provide everyone with another challenge? It can be in any of the categories listed, or you can start a new one.

;-)



2 + | -
Programming Light Sensors-Challenge 1-Forward until dark?
Written by: Jeffrey Rosen On: 12 Aug 2010
To have the program operate as desired you need to set the duration of the move block to a setting of unlimited.  This allows the robot to move until the wait block meets the settings. Hope this helps.


0 + | -
Programming Light Sensors-Challenge 1-Forward until dark?
Written by: mc On: 20 Jul 2010

Can you tell me why the attached NXT program (.rbt) ForwardTilDark.rbt doesn't work?

Educators/Coaches: You're welcome to share this challenge with your students and submit their solution(s).

Also, please submit another challenge. Smile

 

Attachment: 1279634617_ForwardTilDark.rbt (Size: 328 Kb | Hits: 510)

Login to leave a comment