A very quick and dirty introduction to
Sensors, Microcontrollers, and Electronics
Part Two: super basic electronics
You don't need to know much to get started with electronics. We're going to touch very briefly on a few very fundamental concepts with the goal of getting to the fun stuff (playing with sensors/actuators) as quickly as possible. That being the case, these are basically just some quick definitions of terms. Pointers to more information are included in each section.
What are voltage, current, resistance, and power?
voltage: the difference in electrical potential between two points. Voltage is measured in volts.
current: the volume of electron flow. Current is measured in amps.
resistance: something that impedes the flow of electrons. Resistance is measured in ohms.
power: a measure of the total energy available to do work in an electrical system. Power is
measured in watts.
Voltage, current and resistance are related by ohm's law.
What's ohm's law?
Ohm's law tells you the relationship between current (I), voltage (V) and resistance (R):
Using ohm's law is easy. Let's say you have a 9volt battery and you connect the + terminal to the -
terminal through a 100 ohm resistor. How much current would flow?
V = 9
R = 100
I = V/R = 9/100
I = .09 amps (90 milliamps)
So you can see that a given voltage across a given resistance will result in a proportional flow of current. If the resistance is too small (like 0 ohms!) You have a short circuit. That's what would happen if you just touched one terminal of a battery to the other. Looking at ohm's law again, you can see that if R = 0 then you've got a divide by zero problem...And so a super high current. That's bad. Short circuits tend to make the magic smoke come out of things. Don't do that.
How is power measured?
Power is measured in watts (P), and is derived from the simple equation:
That is, power is equal to the voltage times the current used by a circuit. So if you have a 12v motor
that's drawing .5amps, how much power are you using?
V = 12
I = .5
P = VI = 12 * .5 = 6 watts
How Stuff Works has a nice page called
"What are amps, watts, volts and ohms?" with more info.
What's a schematic diagram?
A schematic is a more-or-less formalized way of representing an electronic circuit. Each component (voltage source, resistor, capacitor, diode, IC, transistor, etc.) Has a standard symbol. It's important to note that a schematic doesn't tell you anything about the physical layout of a circuit; it only tells you about the electrical connections.
What are those components you mentioned?
Almost all electronic circuits are built out of just a few basic components. There are often different types of each component. For now you just need a general idea of what these things are.
resistor: A resistor impedes the flow of electrons through a circuit. A resistor has a value, given in ohms. Resistor values range from 1ohm to several mega ohms. A color code on the resistor is used to indicate the value. Some resistors have a variable value; they're called variable resistors. Also important is a resistor's power rating, give in watts. That tells you how much current you can let flow through a resistor before it explodes. Generally the bigger the resistor the more power it can handle. Resistors are not polarized, that is, it doesn't matter which side of a resistor is + and which is -.
resistor schematic symbol (resistor, variable resistor, photoresistor):
capacitor: A capacitor is a device that can store a bit of energy. A capacitor has a value, given in farads. Capacitor values range from really really tiny (picofarads) to a few farads. A farad is huge, and all the circuits you're likely to deal with will use capacitors in the pico-micro farad range. The bigger the capacitor, the more energy it can store. Some capacitors are polarized.
capacitor schematic symbols (non-polarized and polarized):
diode: A diode is a semiconductor with a very special property: current can only flow through it in one direction (more or less). There are lots of different types of diodes with different properties. Generally you use a diode when you want to stop one part of a circuit from "seeing" another part. One special type of diode is the Light Emitting Diode (LED). All diodes emit light when current flows through them, but LEDs are specially designed so that lots of light is emitted. The little lights on your stereo are LEDs. All diodes are polarized.
diode schematic symbols (diode, LED):
transistor: Transistors are the basic building blocks of all integrated circuits (ICs). A transistor can work as either a switch (turn the flow of electrons on or off) or as an amplifier (take a small voltage and make it bigger). Transistors generally have three pins, an emiter, a base and a collector. You've got to connect them the right way or they won't work.
transistor schematic symbols (PNP and NPN):
IC: An IC (integrated circuit) is a bunch of circuits that have been miniaturized and etched into a piece of silicon. They've got a bunch of pins, each of which has a specific function. ICs are non-general. That is, you need to use a particular IC for a particular purpose. A microcontroller is an IC. You might have a squarewave generator IC, an LED display driver IC, an XOR (exclusive OR) IC, and so on.
IC schematic symbol:
voltage source: A power supply. Common power supplies are batteries and wall warts. There are two types of voltage sources: A/C (alternating current) and D/C (direct current). The kinds of circuits you're likely to deal with will mostly be D/C. Voltage is measured in volts. We'll mostly deal with voltages in the DC 0-5v range.
voltage source schematic symbols (battery, +5v, ground):
What's a voltage divider?
A voltage divider is a very common, simple circuit that is used in many sensor schemes. It consists of a voltage source and two resistors:
The voltage at Vout is related to the ratio of R1 to R2. More specifically:
Vout = Vin * (R2/(R1 + R2))
So if R1 = 1k Ohms and R2 = 1K Ohms and Vin = +5v, then:
Vout = 5v * (1000/(1000 + 1000))
Vout = 5v * 1000/2000
Vout = 5v * .5
Vout = 2.5v
Or if R1 = 1k Ohms and R2 = 2K Ohms and Vin = +5v, then:
Vout = 5v * (2000/(1000 + 2000))
Vout = 5v * 2000/3000
Vout = 5v * .666
Vout = 3.3v
And what's a variable resistor again?
A variable resistor is just like a regular resistor, except that its value can be changed. Above we see what happens if we make a voltage divider with two fixed-value resistors. What would happen if we had one fixed resistor and one variable resistor? Then Vout would changed as we changed the resistance of the variable resistor! So if R2 above were a variable resistor that could change from 1000 Ohms to 2000 Ohms, we've seen how Vout would change from 2.5V to 3.3V. As R2 gets bigger and bigger, Vout will get bigger too, until it hits its peak of Vin. Conversely, as R2 gets smaller and smaller Vout will get smaller too, until it hits (almost) 0v (ground).
And why are we spending all of this time talking about variable resistors and voltage dividers? Because there are all sorts of sensors that are essentially variable resistors.
Part Three: how sensors and actuators work and how you hook them up to a microcontroller