Motors and Servos

There are several types of electromechanical devices that generate motion. Two of the most common are motors and servos.

Motors work by using the PWM DutyCycle, just like LEDs. You can use a motor shield or design your own circuitry to connect motors to your Netduino. Just like LEDs, when you increase the DutyCycle motors spin faster; when you decrease the DutyCycle, they slow down.

Circuitry to power motors generally uses an H-Bridge, which is effectively a device that uses the PWM output of your Netduino to supply a much larger amount of power at a voltage proportional to your PWM signal’s “on time.” The PWM signal is combined with a GPIO input specifying whether the motor should spin forward and backward. All together these create a negative or positive analog voltage that spins the motor.

The drawback of using motors is the lack of precision. You can spin them faster or slower, but often you want something to move at a specific speed or move to a specific position. When you want to move between positions, you want to use servos.

Servo Control

Servos create motion by turning forward or backward to specific positions. To demonstrate, I’ll show you a program that moves through various points of a servo’s position range.

To wire up the servo, connect its red wire to the 5V header on your Netduino and its GND wire (usually black, but it might be brown) to a Ground header. Then, connect the signal wire (usually white, but may be another color) to pin D5. Figure 7-2 shows ...

Get Getting Started with Netduino now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.