/** NXT Mindstroms - Actions Dummy (does nothing, describes actions only). @author Piotr Hołownia Motors: 'A', 'B', 'C'. Sensors ports: 'S1', 'S2', 'S3', 'S4'. */ :- module(nxt_actions_dummy,[ nxt_actions_connection_open/0, nxt_actions_connection_close/0, nxt_actions_motor_forward/2, nxt_actions_motor_backward/2, nxt_actions_motor_get_speed/2, nxt_actions_motor_stop/1, nxt_actions_motor_rotate/3, nxt_actions_touch_sensor/2, nxt_actions_sound_sensor/2, nxt_actions_light_sensor/2, nxt_actions_light_sensor_LED/2, nxt_actions_ultrasonic_sensor/2 ]). %% nxt_actions_open_connection % % Opens connection via Bluetooth using iCommand. nxt_actions_connection_open :- writeln('Openning connection...'), writeln('Connected via Bluetooth using iCommand!'). %% nxt_actions_close_connection % % Closes connection via Bluetooth using iCommand. nxt_actions_connection_close :- writeln('Closing connection...'), writeln('Disconnected!'). %% nxt_actions_motor_forward(+Motor,+Speed). % % Rotates motor forward at specified speed. nxt_actions_motor_forward(Motor,Speed) :- write('Rotating motor '), write(Motor), write(' forward at speed: '), write(Speed), write('.'),nl. %% nxt_actions_motor_forward(+Motor,+Speed). % % Rotates motor backward at specified speed. nxt_actions_motor_backward(Motor,Speed) :- write('Rotating motor '), write(Motor), write(' backward at speed: '), write(Speed), write('.'),nl. %% nxt_actions_motor_speed(+Motor,+Speed). % % Gets speed of the motor. nxt_actions_motor_get_speed(Motor,Speed) :- Speed is random(900), write('Motor '), write(Motor), write(' is rotating at Speed: '), write(Speed), write('.'),nl. %% nxt_motor_stop(+Motor). % % Stops motor. nxt_actions_motor_stop(Motor) :- write('Motor '), write(Motor), write(' has been stopped.'),nl. %% nxt_actions_motor_rotate(+Motor,+Speed,+Angle). % % Rotates motor at specified speed. % Forward if Angle is positive, backward if Angle is negative. % Motor will stop, when specified revolution (Angle in degrees) is reached. nxt_actions_motor_rotate(Motor,Speed,Angle) :- write('Rotating motor '), write(Motor), write(' at speed: '), write(Speed), write('. '), write('Angle limit: '), write(Angle), write('.'),nl. %% nxt_actions_touch_sensor(+Port,-Value). % % Gets touch sensor reading. % Returns 1 if pressed, 0 otherwise. nxt_actions_touch_sensor(Port,Value) :- Value is random(1), write('Touch sensor connected to port '), write(Port), write(' returns: '), write(Value), write('.'),nl. %% nxt_actions_sound_sensor(+Port,-Value). % % Gets sound sensor reading. nxt_actions_sound_sensor(Port,Value) :- Value is random(1000), write('Sound sensor connected to port '), write(Port), write(' returns: '), write(Value), write('.'),nl. %% nxt_actions_light_sensor(+Port,-Value). % % Gets light sensor reading. nxt_actions_light_sensor(Port,Value) :- Value is random(100), write('Light sensor connected to port '), write(Port), write(' returns: '), write(Value), write('.'),nl. %% nxt_actions_light_sensor_LED(+Port,+Setting). % % Sets the LED on if Setting is activate or off if passivate. nxt_actions_light_sensor_LED(Port,Setting) :- write('Light sensor LED connected to port '), write(Port), write(' has been set to: '), write(Setting), write(' state. '),nl. %% nxt_actions_ultrasonic_sensor(+Port,-Value). % % Gets ultrasonic sensor reading. nxt_actions_ultrasonic_sensor(Port,Value) :- Value is random(255), write('Ultrasonic sensor connected to port '), write(Port), write(' returns: '), write(Value), write('.'),nl.