# Circuit Diagrams

Electrical Engineers (and us) need a way of conveying their designs to colleagues and collaborators, so a standard visual language was developed to make it clear how a circuit works. Circuit Diagrams are essentially drawings of the circuit you want to build, except all the components are simplified into meaningful icons.

In this image, it’s easy to see how the real-life components are converted into a symbolic diagram.

Here are a few examples of common electronic components, and what they look like as circuit symbols.

### Exercise 1.1: Drawing Your Circuit

Remember the circuit that you built last class? The one that used the power supply and resistor to light up an LED?

• Draw it on the table as a Circuit Diagram.

### Exercise 1.2: Fritzing

There exists software that makes it easy to create Circuit Diagrams. Professional applications, like Eagle or Altium, are too expensive for us (and they do way more things than what we need). A free and open-source piece of software though, called Fritzing, is exactly what we’re looking for.

One of the great things about Fritzing, is there’s a huge library of existing parts aleady included, other people/companies have repositories of their own parts that you can add and use (Sparkfun, for example, has a Github repo with all of their parts), and it’s easy to create your own parts to use.

2. In the Breadboard tab, add the components that you used in your LED circuit (the Arduino version, not the Power Supply version), and wire it up
3. In the Schematic tab, make sure everything looks correct to how you designed your circuit

# Transistors & Actuators

## Transistors

Since you shouldn’t (and usually can’t) power high-draw devices using the Arduino, you should power them via an external power supply. But what if you want to control when they receive power? You can do that with a Transistor.

Transistors are essentially switches, except they are switched open and closed with electricity instead of a mechanical action. They exist in two main forms (at least with what we’ll be using): BJTs (Bipolar Junction Transistor) and MOSFETs (Metal-Oxide Semiconductor Field-Effect Transistor).

This example shows a high-power LED being powered by a 5V power source, but being controlled by a Transistor hooked up to a microcontroller. When the control voltage goes `HIGH`, the electricity is allowed to pass through. When it goes `LOW`, no electricity can pass through the transistor, so the LED can’t turn on.

There are two types of BJTs — NPNs and PNPs.

In diagrams, the arrows for both are on the Emitters. On an NPN, the arrow is NOT POINTING IN. On a PNP, the arrow DOES POINT IN.

On an NPN transistor, the Emitter is connected to Ground, Collector is connected to the Current source you want to pass through, and the Base is connected to the Current source you want to use to control the Transistor. In PNP transistors, the Emitter and Collector are switched.

MOSFETs are very similar, except their pins are named Source, Drain, and Gate. Additionally, the two types are N-Channel and P-Channel.

In diagrams, the arrows are always on the Gate. On N-Channel MOSFETS, the arrow points IN, and on P-Channels it points OUT.

In an N-Channel MOSFET, the Source is connected to ground, the Drain is connected to your high-powered circuit, and the Gate is connected to the control to switch the MOSFET on or off. In P-Channel MOSFETS, the Source and Drain are switched.

## DC Motors

DC Motors are a very simple type of motor that turns at varying speeds depending on how much voltage is supplied.

They are exteremely simple to use. Simply connect one wire to power, and the other wire to ground to make the motor spin one way. Flip the wires around to make it spin the other way. You can determine what Voltage to use by looking at the motor’s datsheet.

These motors, for example, have a suggested Voltage of 4.5V DC, and will pull 250mA of current at max load.

### Exercise 2.1: Using a Transistor to Control a DC Motor

1. Connect your motor to a Power Supply, and give it 4.5V to see it spin. Flip the wires around the other way to see it spin backwards
2. Design (draw or make in Fritzing) and build a circuit using an N-Channel MOSFET to power that motor via a Power Supply, and control it via an Arduino (you should use the Blink example as a starting point)

## Servos

Servos are a little more complicated than regular DC motors. While generally not as strong, you can control the exact speed at which a servo turns, as well as the direction and position it turns to.

To do this, Servos have three wires: Ground, Power, and Control. The colors vary on different servos, but for the most part, red is usually power, black/brown is usually ground, and white/yellow is usually control.

Servos have some limitations. Most servo motors cannot rotate continuously; cheaper servos can have as little as 90° of rotation. Some servos, however, are known as continuous rotation, and can rotate in full circle indefinitely.

Exact control of a hobby servo is accomplished by sending a series of pulses to the device over the control line. We usually don’t generate our own pulses (they’re difficult to keep track of), and instead rely on existing libraries that have all of the potential commands already written.

### Exercise 2.2: Controlling a Servo with a Potentiometer

1. Connect a servo to your Arduino like so:

1. Open the example code, File > Examples > Servo > Sweep, and upload it to your Arduino
2. Attach a Potentiometer to your system, and use it to control the exact positioning of the Servo (make use of the `map()` command)

## Stepper Motors

Stepper Motors are a third type of motor we can use in the course. They have the benefits of both DC motors and Servos, in that they are strong, fast, and controllable for position, direction, and speed. It works by actually stepping the axle in discrete increments using electromagnetics.

### Exercise 2.3: Working with Stepper Motors

The standard IDeATe stepper has 4 wires: red, blue, green, and black. They are meant to be in pairs, so let’s pair them off:

• Take two wires and touch them together. If they make the axle harder to turn, they are a pair. If they don’t, try switching one of the wires for a different colored one.
• Follow the wiring diagram above. Don’t forget to use the 100uF capacitor between the motor power wires.
• Use the following code to test your hardware setup:

Sources:

Joshua Noble’s Circuit Diagram Symbols – Programming Interactivity
Tom Igoe’s Understanding Electricity
Sparkfun’s Voltage, Current, Resistance, and Ohm’s Law, How to Read a Schematic, Motors and Selecting the Right One, and Hobby Servo Tutorial
ITP’s Electricity: the Basics
cmuphyscomp’s physcomp-examples
Oscar Liang’s How to Use MOSFET — Beginner’s Tutorial
Adafruit’s What is a Stepper Motor