Introduction: Telepresence Robot: Collision Switch

Picture of Telepresence Robot: Collision Switch

By now we have already encountered a switch or two in building robots. One cool thing you can do with switches is sense whether or not it is closed by using an Arduino. By combining this principal with a lever switch, we can make a rather effective collission sensor. This allows the robot to know whether or not it has crashed into something. Using this technique, your robot can very easily tell something is in its way and it needs to stop driving and/or change direction.

This is the third part of a seven-part instructables series. Over the next two instructables we will be building the basic electromechanical robot platform. This platform will later be enhanced with sensors and additional control electronics.

To learn more about the topics covered in this series of projects check out the Robot Class, Electronics Class, and Arduino Class.

Step 1: Materials

Picture of Materials

For the collision switches you will need:

(x2) SPST lever switch
(x2) 8" zip ties
(x2) 3/16" x 2" shrink tube
(x2) 10K resistor
(x1) CD**
(x1) 1/4" fender washer
(x1) 1" round PCB (or similar)***

** For attaching the switches to the underside of the robot.
*** This is to be used as a drilling guide for measuring mounting holes. The board itself will be used in the next lesson.

Step 2: The Switch Circuit

Picture of The Switch Circuit

As mentioned, a switch makes or breaks an electrical connection. By building a particular circuit, we are able to use the Arduino digital input pins to tell whether or not a switch is making or breaking a connection.

To build this circuit all we need is a switch and a 10K resistor.

We first connect the 10K resistor between the 5V power source and the input pin. By doing this, we are essentially connecting the digital input pin to power, and the Arduino reads this pin as being "HIGH" or 5V.

The magic comes in when we connect the switch between the digital input pin and ground. When the switch is not being pressed, it is like it is basically not there. However, when the switch is pressed, the pin no longer is connected to 5V, but is connected to ground instead.

You might be confused as to why, but this has to with the path of least resistance. The switch has no resistance, and offers electricity the easiest path to flow. So, electricity flows between the digital pin and ground, and bypasses the path that leads from the resistor to power. This configuration lets the switch toggle between power and ground without shorting any wires.

Step 3: Serial Monitor

Picture of Serial Monitor

We can see whether or not the switch is being pressed by using the Arduino's Serial Monitor.

The Serial Monitor allows the Arduino to "speak" to your computer and report back its current state. It can tell you the value of a variable at any given time or let you know what part of the code you are looking at. In our case, we will be using it to tell whether or not a button is pressed.


To test it out, select the "Serial Monitor" icon (the little magnifying glass) from the bottom left sidebar and then upload the following code:

When it is pressed, the code will return "PRESSED" in the Serial Monitor. When not pressed the code will return "RELEASED"

Step 4: Mark and Drill the CD

Picture of Mark and Drill the CD

Align the outer edge of the PCB with the outer edge of the CD. The axis the PCB's mounting holes are on should be running parallel to an imaginary horizontal line drawn through the center of the CD (or in our case an actual horizontal band). Mark the PCB's mounting holes on the surface of the CD.

Align the switches mounting holes with the two markings such that they are positioned with their levers pointing outwards (away from each other). The switches should also be rotated slightly inwards, such that they are not perfectly horizontally aligned.

Mark the remaining outer mounting hole on each of the switches on the CD.

Drill the four marking with a 1/8" drill bit.

Step 5: Attach the Switches

Picture of Attach the Switches

Using the holes drilled in the CD, firmly zip tie the switches in place. Clean up the loose zip tie ends.

Step 6: Resistor Wire

Picture of Resistor Wire

Solder a resistor to the end of a red 12" solid core wire.

Trim away any excess wire leads.

This will be used to connect the digital input pin to power.

Step 7: Connect Wires

Picture of Connect Wires

Find the two tabs on the switch that point inwards towards each other. These are the ones that should be practically touching already.

Pass the free end of the 10K resistor between the tabs of each respective switch. Solder the resistor to the tabs.

Next, wrap the end of a green 12" solid core wire around these tabs. Solder this wire in place as well.

This is the wire that will be used to connect to the digital input pin on the Arduino.

Step 8: Connect Ground

Picture of Connect Ground

Find the two tabs on the underside of each switch.

Connect them together with a short black wire. Solder this wire securely in place.

Select either one of the tabs connected to the black wire and solder a longer 12" black solid core wire to it.

Step 9: Drill a Hole

Picture of Drill a Hole

In an ideal world, the opening in the CD will align perfectly with with the slider's bolt. However, like me, you probably don't live in an ideal world. Instead, you are going to need to drill a new hole.

To begin, remove the slider by unthreading its nut.

Position the CD such that the switches are at the edge of the lid, and make a mark to indicate on the CD where it aligns with the hole for the slider.

Drill through this mark with a 1/4" drill bit.

Step 10: Another Hole

Picture of Another Hole

Drill a 1/4" hole in the lid near the servo motors.

The exact position is not remarkably important. This hole is simply going to be used to pass the wires from the sensors up into the plastic box.

Step 11: Attach the CD

Picture of Attach the CD

Thread a 1/4-20 nut to the bottom of the slider's bolt, and then place a 1/4" fender washer onto the bolt.

Next, insert the bolt through the 1/4" hole in the CD.

Lastly, pass the bolt up through the hole in the lid, and thread a 1/4-20 nut on such that the bolt protrudes about 1/8" out of the top.

Once all of that is complete, insert the wires from the switch up through the 1/4" hole in the lid.

Step 12: Plug in the Switches

Picture of Plug in the Switches

Plug the red switch wire in the 5V socket, the black wire into one of the ground sockets, and the green wire into digital input pin 2.

Step 13: Program the Arduino

Picture of Program the Arduino

Program the Arduino with the following code:

The robot should now drive forwards until hits something. When it does, it should backup, turn slighly and drive forwards again.

Step 14: Close the Case

Picture of Close the Case

Once programmed, fasten the lid back on, and tighten to the nut on the slider to lock the CD in place.

Step 15: Make Antennae

Picture of Make Antennae

The zip tie antennae do more for your robot than make it look ridiculously cute. They are actually accomplishing two very useful things.

First off, they extend the length of the switch's levers. This allows the levers to cover the the entire front end of the robot and prevents any unexpected surprises and helps alleviate a corner getting snagged.

Secondly, by extending the length of the lever, they are also making it easier for the lever to be pressed down. This is just basic physics. The longer of a lever you use, the easier it is to exert a force. In other words, it makes the switch much more sensitive. Thus, you don't need to crash into things as hard to press the lever down and this is all-around a positive thing.

To make antennae, simply take a long zip tie and connect the tail end to the switch's lever using heat shrink tube.

Easy as that!

Step 16: Test

Picture of Test

Power it up, let it loose, and see what happens.

Don't be afraid to experiment.

Comments

abhay2 (author)2017-10-03

what if we connect the arduino +5 volt to arduino pin 2 and put the switch in between

mcoast made it! (author)2016-09-25

It's getting easy to pull wires loose and that caused a couple headaches, as did a dead battery. But it came together and works well. One thing though is the selfie stick throws it off balance, so I taped a counterweight to the top and it stopped tipping.

gene328 made it! (author)2016-07-21

Some how I lost my photos of the robot with the selfie stick so I'll
go ahead and show the photos with the selfie stick and the collision
switch on it.

randofo (author)gene3282016-07-21

Lookin' good. I like the zip tie loops.

You might as well post one of these pictures to the other project also so it marks it complete :)

gene328 (author)randofo2016-07-21

Thanks!!

Steve_Lane63 made it! (author)2016-07-17

I enjoyed this lesson, as the robot begins to become more sophisticated. Only trouble I had was the robot wanted to travel backwards instead of the direction with the "whiskers". I still don't know why it did that because it had been traveling in the correct direction before I uploaded the last code. I ended up simply flipping the drives, and it worked beautifully.

randofo (author)Steve_Lane632016-07-18

I don't know. but it likely has something to do with the code. I would have to see the code and wiring to understand. But... It sounds like it is working... So... I'm not sure you should worry too much for now... If it happens again in the future, let me know and we can take a look at it.

Anyhow, this is looking great.

About This Instructable

3,129views

10favorites

License:

Bio: My name is Randy and I founded the Instructables Design Studio. I'm also the author of the books 'Simple Bots,' and '62 Projects to ... More »
More by randofo:Large Motor ProjectsRemove a Wheelchair Motor BrakeBuild a Robot
Add instructable to: