Most object avoidance is done with one of two methods:sonic or visible/near visible spectrum EM sensing. Infrared and "Ping" sensors each are well documented for use with the Arduino, so I've been experimenting with static electricity as an object avoidance method. Nearly every object in an environment that a table-top robot would come into contact with has a detectable static field reaching a few inches into space around it. With an array of sensitive enough detectors (and enough shielding or programming regulation to keep from detecting its own fields) a robot should be able to avoid most objects. (Of course if you're mean to your robot and line its environment with the little bags and foam from your IC collection, it won't work, but you'd be being a jerk if you did that...)
In any case, the purpose of this tutorial is just to show how an "Electrometer" works and can be made from an Arduino.
Step 1: Electrometer Basics
Step 2: Parts
-Arduino board (any one should work, but I'm using the UNO.)
-2N3819 JFET (Junction Field Effect Transistor)
-Breadboard and hookup wires
Other materials (optional):
-Soft Dog or Cat
-Roll of packing tape
-natural fiber socks
-glow-in-the-dark analog clock or glow-in-the-dark stickers
-ESD Protection Bag (should have come around your Arduino board.)
This instructable assumes that you're already familiar with Arduino-we're not going to step you through the basics of the IDE. If you have never used your Arduino before, go to Arduino.cc and at least get familiar with the "Blink" and "AnalogReadSerial" demonstration sketches.
In addition, we're going to use Processing to generate a visual "oscilloscope-like" representation of the information that the Arduino gathers and renders to the serial port. If you don't have Processing already, go to https://processing.org/download/ and choose the version appropriate to your OS for download. (Consider making a donation while you're there. It's a neat program for freeware!)
If you are familiar with one of these environments but not the other (or for that matter the Energia IDE used with the Stellaris Launchpads) then the environment you haven't used should look awefully familiar. Arduino and Energia are based on Processing. They each have different default background colors though...
Step 3: Build
The schematic does not reflect the 1MΩ resistor between the antenna and the JFET. It is not completely necessary for the function of the circuit though-it just protects the JFET to an extent. Experiments with it in the circuit and without should have nearly identical results.
(As the schematic diagram notes, you don't have to use an Arduino if you have an Oscilloscope handy-just hook the probe up to the JFET Drain and ground it with about 5v to power, but if you do have the oscilloscope then chances are this instructable is way below your level, and the point of it is to use the Arduino anyway!)
Step 4: Program It...
The second file is PortGraph.pde, which is for the Processing environment. Open this file in Processing with the Arduino IDE still running and the board still connected. Run the program once, and a new output window should draw, but don't worry about it yet-just close it. What we're interested in is the debug window at the bottom. You should see a list of all the ports open on your machine enumerated like this:
 "/dev/tty.usbmodem4b461" and so on...
Switch back to the Arduino environment and under "Tools>Serial Port" see which port has the check next to it*. Then switch back to the Processing environment and look for the line:
myPort = new Serial(this, Serial.list(), 9600);//mine is"/dev/cu.usbmodem4b461"
and replace the bold 3 with the port number in the debug window that corresponds to the port that your Arduino board is on. Save the changes and run the Processing program again (click "Play" or choose "Sketch>Run" from the Menu bar.)
*This is assuming your Arduino sketch uploaded correctly. If it didn't, figure out which port you should be using with standard web resources. It's beyond the scope of this tutorial to teach the basics of Arduino though.
Step 5: Run It...
Step 6: DO SCIENCE!
Experiment with static charges. Use the comb in your hair (or your dog's fur) to charge it up, then bring it near to the antenna or exposed wire. You should see a spike in the Graph and serial values window (as in the image below) as it comes closer. (You might be surprised at how far away it can detect the charge!) Try the same with your balloon, or with a small piece of cellophane. Shuffle across the floor in your socks and bring your finger close to the antenna. Pull a length of packing tape off the roll within a few feet and then inches of the antenna and see what happens. If you have access to a VanDeGraff generator or other electrical discharge apparatus play with it! You may even get a reaction from a glow-in-the-dark sticker or clock hand. This is a fairly sensitive circuit!
Once you've played with (or demonstrated to a class) the various ways that you can generate a static charge, try putting the ESD protection bag over the antenna and repeating the results. Most of the time, you'll gain confidence in the safety of the shipping materials they use because there won't be a big reaction in the graph anymore. If there is, you may want to reconsider your suppliers...
In any case, I probably won't do an instructable about turning this into a robot sensor. However, I shouldn't have to:if you have built a robot before, it should be pretty obvious how this would work in that context. (The best I can give you would be the code I use if I list it as a project at letsmakerobots.com.) It's all theoretical now, but if it works it will be the first version of it that I've seen!