User Tools

Site Tools


Sidebar

Privacy Policy

News

Version 2.50 is out since Jan 1st 2022


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_readsoundsensor

ReadSoundSensor

The ReadSoundSensor function reads the sound pressure level (loudness) of the sound currently being 'heard' by the sound sensor (Note: Sound sensors are not included with the standard NXT kit)

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

The mode parameter should be one of the following values: “DB” or “DbA” depending if you want the returned value in standard Decibels or A-weighted Decibels.

spl = nxt.ReadSoundSensor( input, mode );

Example - Read sound level on port 1

function OnStart()
{
  nxt = app.CreateNxt();
  app.SetMenu( "Connect,Sound Level" );
}
 
function OnMenu( name )
{
  if( name=="Connect" )
    nxt.ShowDevices();
 
  else if( name=="Sound Level" )
  {
    spl = nxt.ReadSoundSensor( 1, "dB" );
    app.ShowPopup( spl );
  }
}
built_in/nxt_readsoundsensor.txt · Last modified: 2015/03/10 00:16 (external edit)