User Functions:

nxt_connect(struct nxt_remote *nxt_user)
nxt_motor(int port, int speed, int brake)
nxt_motor_rotate(int port, int speed, int degrees)
nxt_setsensor(int port, int sensortype, int sensormode)
nxt_getsensor(int port)
nxt_printmess()
nxt_disconnect()
nxt_gettacho(int port)
nxt_motor_zero()

nxt_connect(struct nxt_remote *nxt_user)
Description:

Connects to the Mindstorms NXT using bluetooth
returns 1 if sucessfull, 0 if fail
(bluetooth acts as a Com port)

Inputs:

*nxt_user:
the address of the structure nxt_remote
that the user created in the main function

Return to top Return to main page

nxt_motor(int port, int speed, int brake)
Description:

This function sets the motor output for NXT
Motor rotation is continuous
returns 1 if sucessfull, 0 if fail

Inputs:

port: (motor connection to NXT)
port_A..........0
port_B..........1
port_C..........2

speed: (value between -100 and 100) -100 is fullspeed Counter Clockwise
100 is full speed Clockwise
0 is no speed

brake: (motor mode)
run/idle........0
run/brake.......1
motor off.......2

Return to top Return to main page

nxt_motor_rotate(int port, int speed, int degrees)
Description:

This function sets the motor output for NXT
Motor rotation is limited by tachometer
returns 1 if sucessfull, 0 if fail

Inputs:

port: (motor connection to NXT)
port_A..........0
port_B..........1
port_C..........2

speed: (value between -100 and 100) -100 is fullspeed Counter Clockwise
100 is full speed Clockwise
0 is no speed

degrees:
number of degrees that motor will turn from current position.

Return to top Return to main page

nxt_setsensor(int port, int sensortype, int sensormode)
Description:

This function sets up the sensor to collect data for the NXT
returns 1 if sucessfull, 0 if fail

Inputs:

port: (motor connection to NXT)
port_1..........0
port_2..........1
port_3..........2
port_4..........3

sensortype:
switch...........1
temperature......2
Light (Active)...5
Light (Inactive).6
Sound(dB)........7
Sound(dBa).......8
Ultrasonic.......11

sensormode:
raw..............0
Boolean.........32

Return to top Return to main page

nxt_getsensor(int port)
Description:

This function gets the sensor data from the NXT.
returns 1 if sucessfull, 0 if fail

Inputs:

port: (motor connection to NXT)
port_1..........0
port_2..........1
port_3..........2
port_4..........3

Return to top Return to main page

nxt_printmess()
Description:

This function prints the last message sent to or recieved from the NXT.
returns 1 if sucessfull, 0 if fail

Inputs:

None

Return to top Return to main page

nxt_disconnect()
Description:

Disconnects to the Mindstorms NXT using bluetooth
tunrs all motors to off/idle
turns all sensors to none
returns 1 if sucessfull, 0 if fail
(bluetooth acts as a Com port)

Return to top Return to main page

nxt_gettacho(int port)
Description:

This function gets the the techometer count for the motor.
result is stored it in nxt_motor_pos_raw[port] and nxt_motor_pos_cum[port].
returns 1 if sucessfull, 0 if fail

Inputs:

port: (motor connection to NXT)
port_A..........0
port_B..........1
port_C..........2

Return to top Return to main page

nxt_motor_zero()
Description:

This function resets the the techometer count for all the motors.
returns 1 if sucessfull, 0 if fail
NOTE: this function will change the tachometer count and thus breat the cumulative count kept by tacho limit

Inputs:

port: (motor connection to NXT)
port_A..........0
port_B..........1
port_C..........2

Return to top Return to main page