30 | | * DEVICES: Mechanical switches |
31 | | * SPST, SPDT, DPDT terminology (w/demo) |
32 | | * Potentiometer - pencil/graphite resistor, multimeter, analog input |
33 | | * THEORY: Digital vs. Analog input |
34 | | * MISC: Survey of other mechanical inputs/uses (e.g. magnetic reed switch, limit switches) |
35 | | * HANDS-ON: ead a switch with a digital input and an analog value from the potentiometer with an analog input. |
| 30 | == Switch terminology == |
| 31 | There are many different types of switches (push button, toggle, knife, etc.), but there is some standard terminology engineers use to describe switches electrically that you should learn along with their schematic symbols: [[Image(https://s.yimg.com/fz/api/res/1.2/ugnRSPnAeeUVpznBx2_30g--/YXBwaWQ9c3JjaGRkO2g9MjgwO3E9OTU7dz01Mzc-/http://slab.concordia.ca/wp-content/uploads/2009/08/spdt.png, align=right)]] |
| 32 | * SPST = Single-Pole, Single-Throw: your push button switch has two leads that are either open or closed |
| 33 | * SPDT = Single-Pole, Double-Throw: a switch with three leads: a common lead that is connected to one of the other two leads based on the switch position. |
| 34 | * DPST = Double-Pole, Single-Throw: two SPST switches with a single control |
| 35 | * DPDT = Double-Pole, Double-Throw: two SPDT switches with a single control |
| 36 | Every possible combination can be found; you can read a clear explanation [http://www.musicfromouterspace.com/analogsynth_new/ELECTRONICS/pdf/switches_demystified_assembly.pdf here] (with good pictures) |
| 37 | |
| 38 | Switches are mechanical, but you don't necessarily have to touch a switch to operate it. Magnets are commonly used to open or close a switch. [https://www.sparkfun.com/products/8642 Magnetic reed switches] are frequently used in alarm systems where a magnet in a door or window opens or closes a switch mounted on the frame. In robotics, a magnet could be mounted on a moving arm and reed switches can be used to determine when the magnet is nearby. |
| 39 | **Exercise**: Use a magnet to operate a reed switch |
| 40 | |
| 41 | == Potentiometer (a variable resistor) == |
| 42 | So far we've only looked at digital inputs: devices that have only two states (open/closed, on/off, high/low, etc.). The real world is not black and white and we often need to determine a shade of gray (where is an arm in its range of motion? How much pressure is the robotic hand applying to that egg?). Analog input devices can measure an input over a continuous range of values. A common example is the volume knob on a radio. A volume control is typically (or at least historically) made using a variable resistor known as a "potentiometer". |
| 43 | |
| 44 | A variable resistor changes its resistance according to some external stimulus (such as turning a knob). You can make a variable resistor yourself using a pencil. |
| 45 | **Exercise**: draw a line on a piece of paper with a pencil; then go back and forth over it with the pencil **many** times so that you have deposited a great deal of graphite on that line. Place one lead of your multimeter at one end of the line (touching the graphite) and place the other lead somewhere in the middle of the line; measure the resistance of the graphite between the leads, then slide the lead in the middle closer and further from the other lead and watch the resistance change on the multimeter. |
| 46 | |
| 47 | A potentiometer is very similar to the resistor you just made. A potentiometer has three leads: one at either end of the resistor and a lead that connects somewhere between the two based on the position of a mechanical knob. See this [https://search.yahoo.com/yhs/search?p=Potentiometer+tutorial&ei=UTF-8&hspart=mozilla&hsimp=yhs-001 tutorial] |
| 48 | **Exercise**: measure the resistance between leads of the potentiometer as you turn the knob. |
| 49 | |
| 50 | A common configuration for a potentiometer is to connect the lead at one end to +5V, the lead at the other end to Gnd, and then as the knob is turned, the voltage at the middle lead varies from 0v to 5v. |
| 51 | **Exercise**:connect your potetiometer as described above and measure the voltage at the center lead as you turn the knob. |
| 52 | |
| 53 | Your Arduino computer has analog input pins that can be used to measure a voltage. See this [https://www.arduino.cc/en/Tutorial/Potentiometer example] and [http://www.instructables.com/id/Arduino-Basics-Using-potentiometers-I-made-it-a/ this one]. |
| 54 | **Exercise**:use your Arduino to turn an LED on when the voltage at an analog input pin exceeds a threshold (see above example) |
| 55 | **Exercise**:use your Arduino to vary the blinking speed of an LED based on the position of a potentiometer |