## Electronics basics

[Resistor color code link](http://www.resistorguide.com/resistor-color-code/)
---
## Voltage
#### Current flows through a circuit;
#### Voltage is the energy that the charges have at a particular place in the circuit.

Sometimes people use the analogy of a water pipe, where voltage corresponds to water pressure, current is the flow rate, and resistance corresponds to constrictions in the pipe.
#### Ohm's Law
The relationship between these quantities is described by Ohm's Law:
#### `I = V / R` or `V = IR`
Where `I` is the current in Amps, `V` describes the voltage range, and `R` is resistance in Ohms.

The picture above shows a way to supply voltage to a protoboard circuit. The Arduino Uno (similar to the Metro) provides 5 V. Note that it can also provide 3.3 V. Note that many microcontrollers are not 5 V tolerant, and can be damaged by more than 3.3 V. Alternatively, you can power your [breadboard](https://learn.sparkfun.com/tutorials/how-to-use-a-breadboard) with an external power supply (any voltage) through a barrel connector to which leads have been soldered.

On the left a schematic and on the right a Tinkercad simulation of the circuit. Below, a measurement of the voltage. The arduino pins at 3.3V (or 5V) and GND act as the "battery".
[Tutorial on breadboard circuits](https://learn.sparkfun.com/tutorials/how-to-use-a-breadboard).

The multimeter is used in the DC voltage mode to measure the voltage around the circuit. The voltage reference or "ground" is chosen to be the negative terminal of the battery. A graph of these voltages is shown on the right procceding around the circuit from A through E and back through the battery to A again.
---
## Current
Ohm's law applies to resistors. Use Ohm's law to calculate the current flowing through a resistor.

An LED does not have the simple relation between voltage and current that a resistor does (Ohm's law does not work for diodes). To learn what current is flowing through the LED, you need to use the fact that the current flowing through the resistor is the same as that flowing through the LED. Then measure the voltage across the resistor and use Ohm's Law to find the current.
Build the circuit shown above, and calculate the current flowing through the circuit.
---
##Kirchhoff's Circuit Laws
[Kirchhoff's current law](https://en.wikipedia.org/wiki/Kirchhoff%27s_circuit_laws) states that, for any node (junction) in an electrical circuit, the sum of currents flowing into that node is equal to the sum of currents flowing out of that node.

The current entering any junction is equal to the current leaving that junction. _i2 + i3 = i1 + i4_
Kirchhoff's Voltage Rule states that the directed sum of the potential differences (voltages) around any closed loop is zero.

_v1 + v2 + v3 + v4 = 0_
---
##Resistance

---
##Arduino as a voltmeter

Use the Arduino as a voltmeter. In the picture above, the A0 pin of the Arduino is used with the yellow lead, to measure
voltage, using analogRead. Use the program in Arduino IDE, File>Examples>Basic>AnalogReadSerial. Open the serial monitor
or the serial plotter in the Arduino IDE. Probe the circuit to measure voltages relative to ground.
---
##Power
Power is the energy per unit time that is used or dissipated by a circuit element. It is calculated as:
P = I x V
With current in Amperes and V in volts, Power has units of Joules/second or Watts.
Alternatively, Ohm's Law can be used to give:
P=I2R or P=V2/R
---
##Voltage Divider

- Voltage divider. Here is a voltage divider, which forms the basis for many sensors. Build this circuit
with resistors, and measure voltages. Does it make sense to you?
---

- Potentiometers. A potentiometer is a voltage divider with a movable contact. It can be used to provide a variable voltage, or act
as a variable resistance.
---
## Capacitors, time-varying voltage, Oscilloscope

- A capacitor stores energy within its internal electric fields. As current flows through the capacitor, the voltage across its teminals
increases as V = (1/C)*Q where C is the capacitance in Farads and Q is the total charge that has passed through the capacitor.
- [Applet by Falstad demonstrating capacitor charging](https://www.falstad.com/circuit/e-cap.html)
- Oscilloscope.

- Use Oscilloscope to measure voltage of Arduino as it blinks.
- Use the Oscilloscope to monitor capacitor voltage as it charges.
## Resources
[Makeability Lab Intro to Electronics](https://makeabilitylab.github.io/physcomp/electronics/)
_Thanks to Rob Hart, Gabby Perry_