The RedBot Mechanical Bumper is an add-on for the RedBot Mainboard or RedBot Kit that that gives your robot the ability to detect a collision before it really happens. This sensor works by acting as an SPST switch. When the "whisker" bumps into a foreign object, it will make contact with a nut next to it, closing the connection. Your robot's program would detect that connection and turn off the motor and/or perform some other action (e.g. play a sound, back up, etc.). By attaching these mechanical bumpers to your robot, the whisker will bump something before your robot crashes into it.
Only one bumper kit is included with your purchase, so make sure to buy as many as you need. It's recommended to have two at the front of your robot — one "whisker" per side.
The sensor board measures 1.03 × 0.69 inches (26.27 × 17.67 mm) and has a 3-pin header which connects directly to the RedBot Mainboard via female-to-female jumper wires (not included). Use the RedBot Arduino Library to make sure your robot never crashes into anything again. The library includes commented code examples for using the RedBotBumper class with this sensor. Two mounting holes lets you easily connect this sensor to your robot chassis (and serve as the contact points for the "whisker").
The "whisker" wire is shipped straight. You will have to bend it yourself. The RedBot Assembly Guide shows the recommended method. For safety reasons, you might also want to curl the protruding end of the wire.
RedBot Mechanical Bumper Kit Contents
- Mechanical Bumper board
- Whisker wire
- ¾" 4-40 nylon standoff
- 4-40 hex nut
- Three ¼" 4-40 Phillips screws
RedBot Mechanical Bumper Usage The RedBot Arduino Library's documentation does not cover usage this mechanical bumper. However, if you open the Library_Test example sketch in Arduino/libraries/RedBot/Library_Test, it is well commented.
Below is an overview of how the library's support is implemented. The "actual code example" is how the library's support is implemented in the Library_Test sketch. You can search for each of those text strings within the sketch to see the context of each command and the comments relating to them.
RedBotBumper(int pin); RedBotBumper(int pin, &bumpHandler); These two constructors are the only functions relating to the bumper. The first one will cause any falling edge on pin to stop the motors. The second one will cause a falling edge on pin to call function bumpHandler(), where bumpHander() is a user-created function that accepts no parameters and returns no values. You can name bumpHandler() anything you want, or even use an existing function in your code. Just note that the function executes in interrupt time, so other functions like delay(), millis() and serial read/write/print will not work properly within the handler function. It is best for the handler to do only something simple like set a flag, then have the main code loop deal with the ramifications of that flag.
Also, you can have different handlers for different bumpers if you like. The code used in the Library_Test sketch uses two bumpers, but each calls the same handler routine, in this case called bump(). See the code below.
Actual code example:
RedBotBumper lBumper(10, &bump);
RedBotBumper rBumper(11, &bump);
volatile boolean bumped = true;
bumped = true;
tone(BEEPER, 150, 750);
Look through the example sketch to see these lines in their proper context.
RedBot Mechanical Bumper Resources