This shows you the differences between two versions of the page.
built_in:nxt [2015/03/03 12:42] madlyr [Methods] Added ToColorName(colorNum) |
built_in:nxt [2015/04/18 18:02] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== NXT control ====== | ||
- | |||
- | The NXT object is used to manage the connection between your Android phone and the NXT brick. | ||
- | |||
- | ===== Create ===== | ||
- | Create an NXT object using the CreateNxt function of the app object: | ||
- | < | ||
- | |||
- | ===== Methods ===== | ||
- | ^Method ^Description ^ | ||
- | |Beep(frequency, | ||
- | |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/ | ||
- | |Disconnect() |Disconnects the Bluetooth link between your phone and the NXT brick. | | ||
- | |Drive(motors, | ||
- | |GetCurrentProgram() |Gets the name of the NXT-G program currently running on the NXT brick. | | ||
- | |IsBluetoothEnabled() |Checks if Bluetooth is enabled on the phone/ | ||
- | |IsConnected() |Returns true if the NXT brick is currently connected to the phone/ | ||
- | |IsMotorIdle(motor) |Checks if the specified **motor** (" | ||
- | |PlaySoundFile(file, | ||
- | |ReadColorSensor(input, | ||
- | |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). | | ||
- | |ReadMail(mailbox, | ||
- | |ReadLightSensor(input, | ||
- | |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). | | ||
- | |ReadSoundSensor(input, | ||
- | |SendMail(mailbox, | ||
- | |SetInvert(boolean) |Provides a convenient way to invert the direction of the motor commands. | | ||
- | |SetLampColor(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. | | ||
- | |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. | | ||
- | |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. | | ||
- | |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 " | ||
- | |StopProgram() |Stops the NXT-G program (.rxe file) which is currently running on the NXT brick. | | ||
- | |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. | |