Section 5.1 - Motors and Encoders
Making Things Spin
In this lesson, you’ll delve into the fundamentals of motors, encoders, and motor drivers to gain a hands-on understanding of controlling motor speed and direction with an Arduino. Beginning with a simple setup, you’ll first connect a motor directly to a 9V battery to observe how it operates under a continuous power supply, followed by connecting it to a digital pin on the Arduino. Through this process, you’ll learn why directly controlling a motor with digital signals is limited—covering motor physics, key components, and the issue of reaching optimal RPM without additional hardware. To address these limitations, you’ll be introduced to the L293D motor driver, a device that enhances control over the motor's speed and direction. The lesson includes step-by-step guidance on wiring the L293D with an Arduino, accompanied by a coding demonstration. After learning the basic code setup, you’ll practice by coding a simple task: make the motor run for 5 seconds and then stop. This activity helps reinforce core programming concepts and shows the practical application of motor drivers for precise motor control.