User Tools

Site Tools


Privacy Policy


Version 2.50 is out since Jan 1st 2022

Frequently Asked Questions


Note for contributors

If you wish to create a new page in the DroidScript wiki, please click on the most appropriate namespace above and follow the notes for contributors there.

Because of spam, it has been necessary to add a CAPTCHA to the registration form and the save option for editing pages. You will not need to prove you are human if you are logged in, so please register.

Please feel free to improve any existing page, as well as adding new pages to increase the sum of public knowledge about DroidScript.

Formatting Syntax



The ReadColorSensor function reads the color currently being 'seen' by the NXT color sensor. (Note: brick firmware 1.28 or greater is required for this function)

The input parameter should be an NXT input port number between 1 and 4 (which the color sensor is plugged into).

The mode parameter should be one of the following values:

  • “ColorDetect”
  • “LightSense”
  • “RedSense”
  • “GreenSense”
  • “BlueSense”

If the mode ColorDetect is chosen, then the returned values will be a number between 1 and 6 which represent the following colors: black, blue, green, yellow, red, white.

You can use the ToColorName function to convert from these six values to a color name

If any of the other modes are chosen, then the result will be a color intensity value between 0 and 1023.

val = nxt.ReadColorSensor( input, mode );

Example - Sense color on port 3

function OnStart()
  nxt = app.CreateNxt();
  app.SetMenu( "Connect,Sense Color" );
function OnMenu( name )
  if( name=="Connect" )
  else if( name=="Sense Color" )
    clr = nxt.ReadColorSensor( 3, "ColorDetect" );
    app.ShowPopup( nxt.ToColorName( clr ) );
built_in/nxt_readcolorsensor.txt · Last modified: 2015/03/22 02:35 (external edit)