Wiring up servos and motors

Wiring up servos will look similar to wiring up sensors, except the signal maps to an output. Wiring up a motor is similar to wiring up an LED.

Wiring up servos

To wire up a servo, you'll have to use a setup similar to the following figure:

Wiring up servos

A servo wiring diagram

Tip

The wire colors may vary for your servo. If your wires are red, brown, and orange, red is 5V, brown is GND, and orange is signal. When in doubt, check the data sheet that came with your servo.

After wiring up the servo, plug the board in and listen to your servo. If you hear a clicking noise, quickly unplug the board—this means your servo is trying to place itself in a position it cannot reach. Usually, there is a small screw at the bottom of most servos that you can use to calibrate them. Use a small screwdriver to rotate this until it stops clicking when the power is turned on.

This procedure is the same for continuous servos—the diagram does not change much either. Just replace the regular servo with a continuous one and you're good to go.

Wiring up motors

Wiring up motors looks like the following diagram:

Wiring up motors

A motor wiring diagram

Again, you'll want the signal pin to go to a PWM pin. As there are only two pins, it can be confusing where the power pin goes—it goes to a PWM pin because, similar to our LED getting its power from the PWM pin in Chapter 2, Working with Johnny-Five, the same pin will provide the power to run the motor.

Now that we know how to wire these up, let's work on a project involving a motor and Johnny-Five's REPL.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.137.218