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/03 12:42] madlyr [Methods] Added ToColorName(colorNum) |
built_in:nxt [2015/03/21 18:27] madlyr [Table] |
||
---|---|---|---|
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 |
- | ===== Create | + | ===== Description |
- | Create an NXT object using the CreateNxt function of the app object: | + | Create an NXT object using the **CreateNxt** function of the **[[built_in: |
< | < | ||
===== Methods ===== | ===== Methods ===== | ||
- | ^Method ^Description ^ | + | ^ Method |
- | |Beep(frequency, | + | | [[nxt_beep|Beep( frequency, duration )]] |
- | |Brake(motors) |Commands the NXT brick to Brake one or more of it's motors.\\ The **motors** parameter can be a single motor, for example just " | + | | [[nxt_brake|Brake( motors )]] | Commands the NXT brick to Brake one or more of it's motors.\\ The **motors** parameter can be a single motor, for example just " |
- | |CheckConnection() |Returns true if the NXT brick is currently connected to the phone/ | + | | [[nxt_checkconnection|CheckConnection()]] | Returns true if the NXT brick is currently connected to the phone/ |
- | |Disconnect() |Disconnects the Bluetooth link between your phone and the NXT brick. | | + | | [[nxt_connect|Connect( p1 )]] |
- | |Drive(motors, | + | | [[nxt_disconnect|Disconnect()]] | Disconnects the Bluetooth link between your phone and the NXT brick. |
- | |GetCurrentProgram() |Gets the name of the NXT-G program currently running on the NXT brick. | | + | | [[nxt_drive|Drive( motors, power, rotation )]] |
- | |IsBluetoothEnabled() |Checks if Bluetooth is enabled on the phone/ | + | | [[nxt_filefindfirst|FileFindFirst( p1 )]] |
- | |IsConnected() |Returns true if the NXT brick is currently connected to the phone/ | + | | [[nxt_filefindnext|FileFindNext( p1 )]] |
- | |IsMotorIdle(motor) |Checks if the specified **motor** (" | + | | [[nxt_getbtaddress|GetBtAddress( obj )]] | Returns Bluetooth address of a connected NXT brick or NXT brick address given as optional **obj** parameter. |
- | |PlaySoundFile(file, | + | | [[nxt_getbtname|GetBtName( obj )]] | Returns Bluetooth name of a connected NXT brick or NXT brick name given as optional **obj** parameter. |
- | |ReadColorSensor(input, | + | | [[nxt_getcurrentprogram|GetCurrentProgram()]] | Gets the name of the NXT-G program currently running on the NXT brick. |
- | |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_isbluetoothenabled|IsBluetoothEnabled()]] | Checks if Bluetooth is enabled on the phone/ |
- | |ReadMail(mailbox, | + | | [[nxt_isconnected|IsConnected()]] | Returns true if the NXT brick is currently connected to the phone/ |
- | |ReadLightSensor(input, | + | | IsEnabled() |
- | |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_ismotoridle|IsMotorIdle( motor )]] |
- | |ReadSoundSensor(input, | + | | [[nxt_ispaired|IsPaired( p1 )]] |
- | |SendMail(mailbox, | + | | [[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. |
- | |SetInvert(boolean) |Provides a convenient way to invert the direction of the motor commands. | | + | | [[nxt_readcolorsensor|ReadColorSensor( input, mode )]] |
- | |SetLampColor(input, | + | | [[nxt_readdistancesensor|ReadDistanceSensor( input )]] |
- | |SetOnConnected(myfunc) |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. | | + | | [[nxt_readmail|ReadMail( mailbox, type, remove )]] |
- | |ShowDevices() |Shows the user a dialog box that contains a list of NXT bricks which are paired with the phone. The user can then select the brick to connect to via Bluetooth. | | + | | [[nxt_readlightsensor|ReadLightSensor( input, active )]] |
- | |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_readtouchsensor|ReadTouchSensor( input )]] |
- | |Stop(motors) |Commands the NXT brick to Stop powering one or more of it's motors and allow them to coast to a halt.\\ The **motors** parameter can be a single motor, for example just " | + | | [[nxt_readsoundsensor|ReadSoundSensor(input, |
- | |StopProgram() |Stops the NXT-G program (.rxe file) which is currently running on the NXT brick. | | + | | [[nxt_requestenable|RequestEnable()]] |
- | |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 ReadColorSensor with mode set to ColorDetect. | | + | | [[nxt_sendmail|SendMail( mailbox, type, message |
+ | | [[nxt_setinvert|SetInvert( boolean )]] | ||
+ | | [[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 )]] | 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. | ||
+ | | [[nxt_showdevices|ShowDevices()]] | Shows the user a dialog box that contains a list of NXT bricks which are paired with the phone. The user can then select the brick to connect to via Bluetooth. | ||
+ | | [[nxt_startprogram|StartProgram( program )]] | ||
+ | | [[nxt_stop|Stop( motors )]] | Commands the NXT brick to Stop powering one or more of it's motors and allow them to coast to a halt.\\ The **motors** parameter can be a single motor, for example just " | ||
+ | | [[nxt_stopprogram|StopProgram()]] | Stops the NXT-G program (.rxe file) which is currently running on the NXT brick. | ||
+ | | [[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 |