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, 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?

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?

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.

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