If you are looking for the Chapter 4 content for the 2nd Edition of Exploring Arduino, please click here.
Using Transistors and Driving Motors
Parts List
- Arduino Uno
- USB A-B Cable
- 9V Battery
- 9V Battery Clip
- 5V L4940V5 Linear Regulator
- 22uF Capacitor
- .1uF Capacitor
- 1uF Ceramic Capacitor
- Blue LEDs (x4)
- 1kΩ Resistors (x4)
- PN2222 NPN BJT Transistor
- Jumper Wires
- Sharp GP2Y0A41SK0F IR Distance Sensor with Cable
- Hot Glue or Tape
- Servo Motor
- DC Motor
- Breadboard
- Potentiometer
- SN754410 H-Bridge IC
- 1N4004 Diode (mistakenly omitted from the parts list in the first edition print of the book)
Code
Download Code (1st Edition, Chapter 4)
(Also available on GitHub)
Useful Links
- Arduino map() Function Reference
- Arduino constrain() Function Reference
- Arduino Servo Library Reference
- SN754410 H-Bridge Datasheet (PDF)
- PN2222 Datasheet (PDF)
Errata
- On page 73, in the “Creating Short Circuits with H-Bridges” excerpt, the book reads: “What would happen if both switches on the left or both switches on the right were opened?” It should read: “What would happen if both switches on the left or both switches on the right were closed?”
- In Figure 4-14, There is a wire missing. The top and bottom GND strips on the breadboard must be connected.
Color Wiring Diagrams
Videos
Follow along with this video for a visual tutorial on motors and transistors:
Watch a demo of the sweeping IR distance sensor created in the chapter: