Detecting Collisions

A simple way to detect collisions is to use a switch and the button press command. This allows you to have the robot react in a certain manner when it collides with or makes contact with an object or another robot.

Push buttons switches are common but a switch can also simply be two wires making contact as shown below. When the two copper wires make contact with a metallic object, such as another JackBord, the switch is closed and the btp command will take the specified action.





 

The two sections of copper are soldered to some wires which will connect to the JackBord. The white plastic in the middle is an insulator and serves as the mount point for the detector as shown below.

The command to use for detecting and counting the collisions is:

           btp a1 inc /crash1

This assumes the sensor is connected to port pin A1 and that we are using the /crash1 variable to count the collisions.