This instructable will teach you how to create bumpers for a robot and how to start off the code so your robot will be up and running in no time. The type of robot you have might differ from how you can attach the bumpers to your robot and how to create the code.
Step 1: Tools You Will Need:
To start off you will need
- a stapler
- little LED lights (optional)
- wire strippers
- pliers (optional)
Step 2: Creating Your Wires
Your wires are the source of energy that helps get the power from the bumpers to the robot. You will want wires to be semi long, but depending on how big your bumper is or how far out from your robot it is, it's going to differ from the size of wire you use. With the wire strippers you will want to strip about 5mm of the rubber off to show the wire on one side and on the other end you will want to cut off about 2cm so you can bend the wire to make a spiral. You will need to do this three more times to have four wires in total, since you will need two wires per bumper and we are going to make two. If you plan on making more than two bumpers then you will just have to make two more wires for each new bumper added. The shorter end of the wire will attach to your robot and the longer spiral side will be attached to your bumper.
Step 3: Wrapping the Wire
After you have stripped your wires you will need to get small pieces of tinfoil to wrap around the spiral side. This will help give the flow of energy a bigger space to connect to. You can wrap it the way you find best fits and with how much you'd like.
Step 4: Connecting Wrapped Wires to Cardboard
Before you start connecting the wrapped wire to the cardboard you will need to set it up. Find a small piece of cardboard in a rectangular form so you can bend it in half. This will give you your base of your bumper. When the cardboard is pushed together the two halves will touch and that's where you will add the wires. On the half you would like closer to the robot add the wire you are planning on attaching to the ground (Vss). To keep the wrapped wire on the cardboard I found it easy to just staple them together, but I found that the wrapped wire didn't cover enough space as I would like to have a bigger space for connection so I added a piece of tinfoil over top of the wrapped wire that covered the whole half. Again just staple it on. On the other half that is going to be pressed by the object it is trying to avoid running through add the wire that will be connected to the pins. Then repeat the process above for each half of the bumpers you make. If you find that your bumpers aren't pressing well then at the crease you can get scissors and cut a line through the cardboard.
Step 5: Attaching Bumpers to Robot
You will want to attach your bumpers to the front of your robot. I found that taping it on is easier. You will need a lot of tape to secure them on right and you will want to try and wrap it around the front part of the robot if possible. How I did it is I folded the tape to be double sided then stuck it on and then I got a bunch more to attach the tape to the top and bottom of the bumper to underneath the robot. The way you want to tape it is up to you, but the more tape you use the better.
Step 6: Setting Up the Wires on the Robot
If you just want to have your buttons connected then you will need two resistors and really only two to three tiny wires. The way you connect your wires to the Vdd and Pins is up to you. You will need to have either a wire or resistor connected to the Vdd and then wires connected to the Pins. The side where the Pin numbers are shown is the way the board connects. Whatever row your wire or resistor is connected from the Vdd will be the same row where your tiny wire gets connected to your Pins and in the same row the wire coming out of the farther half of your bumper will be connected to too. The wire coming from your bumper that is secured on your robot will be connected to the Vdd (Ground). I found it easier to work with lights on the robot to help test if the bumpers are working. The way you would connect LEDs to the breadboard is by connecting the negative side (flat part of the rim around the light bulb) of the LED to the Vdd or a wire that is connected to the Vdd, the positive side to a resistor and the other side of the resistor to a wire that is connected to a Pin number. It would be best to try and measure the length of your wires to have them straight on the board. You can cut them down to side with the wire strippers and use the pliers to bend the legs at a 90 degree angle. This helps keep the board neat and more manageable.
Step 7: The Code
For a basic code you will want to have a loop and all your commands but I did it a bit differently. It isn't hard to make. You will need a "Do" loop to start with and you will most likely want your robot to go forward. In my program I have variables set up for each wheel and each type of direction that knows the speed to run at. The speed values will be different for every robot that's why they aren't shown in the pictures so you will need to figure this out for yourself. The "Pulsout" tells the robot that the motors are going to need to move and I have the pin number the wheels connected to as a variable and the forward speed as a variable. You will need an "If" for each bumper you have. When your bumper equals 0 it means the bumper is being pressed and when your bumper equals 1 then it is not being pressed. I have my program set up in sub methods. My left bumper when pressed lights up an LED and reverses. After it backs up it turns right and goes back to going straight. For my right bumper it turns on another light and goes backwards and then afterwards it turns left. If doing the program with LED you might want to add another "If" for when not being pressed it turns off the light otherwise after the first time the bumper program has run the light will stay on and then you won't be able to tell next time it is working. In your main program when calling your methods you will need to put "Gosub" and then the name of your method to call upon. Don't foreget at the end go your method to put "return" so it knows to go back to the main program. The "Do" loop will make the program keep running continuously and will always be going straight while trying to look for when the bumpers are being pressed. The "For" in the methods will tell your motors how long you will want it to run for (how many rotations). The numbers will vary for everyone. Don't forget to have pauses to let the robot take a break before completing the next time. This will give it time to figure out what it needs to do next.
Step 8: Now Test It Out
There are so many different ways to build your robot but here is just one way I hope will help you understand how to create bumpers. Good luck and have fun!