This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
built_in:nxt [2015/03/10 15:33] madlyr [Table] |
built_in:nxt [2015/03/23 07:43] madlyr [Table] Added IsPaired description. |
||
---|---|---|---|
Line 2: | Line 2: | ||
- | The NXT object is used to manage the connection between your Android phone and the NXT brick. | + | The NXT object is used to manage the connection between your Android phone and the Lego Mindstorms |
===== Description ===== | ===== Description ===== | ||
Line 9: | Line 9: | ||
===== Methods ===== | ===== Methods ===== | ||
- | ^ Method | + | ^ Method |
- | | [[nxt_beep|Beep(frequency, | + | | [[nxt_beep|Beep( frequency, duration )]] | Commands the NXT brick to play a tone of a given **frequency** for a given **duration** in milliseconds. |
- | | [[nxt_brake|Brake(motors)]] | + | | [[nxt_brake|Brake( motors )]] |
- | | [[nxt_checkconnection|CheckConnection()]] | + | | [[nxt_checkconnection|CheckConnection()]] |
- | | [[nxt_disconnect|Disconnect()]] | + | | [[nxt_connect|Connect( p1 )]] |
- | | [[nxt_drive|Drive(motors, | + | | [[nxt_disconnect|Disconnect()]] |
- | | [[nxt_getcurrentprogram|GetCurrentProgram()]] | + | | [[nxt_drive|Drive( motors, power, rotation )]] | Commands the NXT brick to drive one or more of it's motors with a given power and number of rotations.\\ The **motors** parameter can be a single motor, for example just " |
- | | [[nxt_isbluetoothenabled|IsBluetoothEnabled()]] | + | | [[nxt_filefindfirst|FileFindFirst( p1 )]] |
- | | IsConnected() | + | | [[nxt_filefindnext|FileFindNext( p1 )]] |
- | | IsEnabled() | + | | [[nxt_getbtaddress|GetBtAddress( obj )]] | Returns Bluetooth address of a connected NXT brick or NXT brick address given as optional **obj** parameter. |
- | | [[nxt_ismotoridle|IsMotorIdle(motor)]] | + | | [[nxt_getbtname|GetBtName( obj )]] | Returns Bluetooth name of a connected NXT brick or NXT brick name given as optional **obj** parameter. |
- | | [[nxt_playsoundfile|PlaySoundFile(file, | + | | [[nxt_getcurrentprogram|GetCurrentProgram()]] |
- | | [[nxt_readcolorsensor|ReadColorSensor(input, | + | | [[nxt_isbluetoothenabled|IsBluetoothEnabled()]] |
- | | [[nxt_readdistancesensor|ReadDistanceSensor(input)]] | + | | [[nxt_isconnected|IsConnected()]] | Returns true if the NXT brick is currently connected to the phone/ |
- | | [[nxt_readmail|ReadMail(mailbox, | + | | IsEnabled() |
- | | [[nxt_readlightsensor|ReadLightSensor(input, | + | | [[nxt_ismotoridle|IsMotorIdle( motor )]] | Checks if the specified **motor** (" |
- | | [[nxt_readtouchsensor|ReadTouchSensor(input)]] | + | | [[nxt_ispaired|IsPaired( name )]] | Checks if Bluetooth device with **name** is on the paired devices list of our phone/ |
- | | [[nxt_readsoundsensor|ReadSoundSensor(input, | + | | [[nxt_playsoundfile|PlaySoundFile( file, repeat )]] | Commands the NXT brick to play a sound file (.rso) file which is available on the brick.\\ The **file** parameter should be the name of the sound file and the **repeat** parameter should be number of times you want the sound to repeat. |
- | | [[nxt_requestenable|RequestEnable()]] | + | | [[nxt_readcolorsensor|ReadColorSensor( input, mode )]] | Reads the color currently being ' |
- | | [[nxt_sendmail|SendMail(mailbox, | + | | [[nxt_readdistancesensor|ReadDistanceSensor( input )]] | Reads the distance measured by the ultrasonic sensor in centimeters.\\ The **input** parameter should be an NXT input port number between 1 and 4 (which the ultrasonic sensor is plugged into). |
- | | [[nxt_setinvert|SetInvert(boolean)]] | + | | [[nxt_readmail|ReadMail( mailbox, type, remove )]] | Reads a message from the NXT brick' |
- | | [[nxt_setlampcolor|SetLampColor(input, | + | | [[nxt_readlightsensor|ReadLightSensor( input, active )]] | Reads the intensity of the light currently being ' |
- | | [[nxt_setonconnected|SetOnConnected(myfunc)]] | + | | [[nxt_readtouchsensor|ReadTouchSensor( input )]] | Reads the state of the NXT touch sensor, which will be true if the switch is currently pushed in and false otherwise.\\ The **input** parameter should be an NXT input port number between 1 and 4 (which the touch sensor is plugged into). |
- | | [[nxt_showdevices|ShowDevices()]] | + | | [[nxt_readsoundsensor|ReadSoundSensor(input, |
- | | [[nxt_startprogram|StartProgram(program)]] | + | | [[nxt_requestenable|RequestEnable()]] |
- | | [[nxt_stop|Stop(motors)]] | + | | [[nxt_sendmail|SendMail( mailbox, type, message ]] | Sends a **message** to the NXT brick' |
- | | [[nxt_stopprogram|StopProgram()]] | + | | [[nxt_setinvert|SetInvert( boolean )]] | Provides a convenient way to invert the direction of the motor commands. |
- | | ToColorName(colorNum) | + | | [[nxt_setlampcolor|SetLampColor( input, color )]] | Commands the NXT brick to set the **color** sensor lamp to one of the following: ' |
+ | | [[nxt_setonconnect|SetOnConnect( myfunc )]] | The **SetOnConnect** function allows you to set the name of a function that you would like to be called when the NXT has been successfully connected via Bluetooth. Callback function returns status of connection (true if connection is successful, and false, if connection failed) and caller nxt object. | ||
+ | | [[nxt_setonconnected|SetOnConnected( myfunc )]] | ||
+ | | [[nxt_showdevices|ShowDevices()]] | ||
+ | | [[nxt_startprogram|StartProgram( program )]] | Starts an NXT-G **program** (.rxe file) on the NXT brick (if the program is available on the brick).\\ Note: This function will also launch .rso sound files. | ||
+ | | [[nxt_stop|Stop( motors )]] | ||
+ | | [[nxt_stopprogram|StopProgram()]] | ||
+ | | [[nxt_tocolorname|ToColorName( colorNum )]] | Function returns string with one of the six colors: black, blue, green, yellow, red, white converted from **colorNum** parameter.\\ You can use the ToColorName function to convert value obtained from color sensor by method [[nxt_readcolorsensor|ReadColorSensor]] with mode set to ColorDetect. |