Transistors + Motors

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)

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

Leave a Reply