DroidScript wiki

(was AndroidScript) unofficial documentation by the community

User Tools

Site Tools


Sidebar

Privacy Policy

News

Version1.42 is out since December 2nd 2016


Frequently Asked Questions


Namespaces

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

built_in:nxt_readlightsensor

ReadLightSensor

The ReadLightSensor function reads the intensity of the light currently being 'seen' by the NXT light sensor.

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

The active parameter should be set to true if you want the white light to be turned on during sensing and false if the light is not required.

The returned value will be a light level value between 0 and 100.

level = nxt.ReadLightSensor( input, active );

Example - Sense light level on port 3

function OnStart()
{
  nxt = app.CreateNxt();
  app.SetMenu( "Connect,Light Level" );
}
 
function OnMenu( name )
{
  if( name=="Connect" )
    nxt.ShowDevices();
 
  else if( name=="Light Level" )
  {
    level = nxt.ReadLightSensor( 3, false );
    app.ShowPopup( level );
  }
}
built_in/nxt_readlightsensor.txt · Last modified: 2015/03/09 16:12 by octazid