Introduction: Control Servo Via Raspberry Pi Zero

We can easily control Servo motors using Rasrpberry pi and It doesn't matter which version you have.

Servos are small boxes that has a DC motor inside and a gear box, it also has a potentiometer that tracks its position and makes them perfect for going to specific angles.

Small radio control servos are connected through a standard three-wire connection: two wires for a DC power supply and one for control, carrying the pulses.

In this project you will learn how to make a rotating servo that can stop in some position or angle.

Step 1: Parts & Tools

Parts

More than $100

  • 5V Mini Servo Motor
  • Raspberry Pi Zero
  • Mini Usb to Female USB | OTG

  • Usb Hub

  • WiFi-Dongle

  • USB to Ethernet (optional)

  • Mini HDMI to HDMI + USB

  • Jumpers and Breadboard

  • Acrylic Case (Organic Glass)

  • Min 8GB SD card with installed raspbian-jessie OS

  • Mini aluminum cooler (passive radiator)

  • Switcher on/off

Tools

  • Soldering iron
  • Screwdriver
  • Scissor
  • Isolator tape
  • Multimeter

Step 2: Installing Raspbian Jessie OS

  1. Insert SD card in your card reader and put in laptop's SD/MMC Card Adapter (if you have not card adapter, then you can use USB HUB like this: goo.gl/9il4h3, or you can type and search "USB 2.0 Hub 3 Ports with Card Reader Combo for SD MMC" keyword)
  2. Download raspbian-jessie OS from here: https://www.raspberrypi.org/downloads/raspbian/. There are two version: RASPBIAN JESSIE WITH PIXEL and RASPBIAN JESSIE LITE. We'll use first one.
  3. Unzip or decompress downloaded file. It's much better to use 7zip program. After unzipping you'll see the .img file.
  4. Download and install Win32 Disk Imager from https://sourceforge.net/projects/win32diskimager/, if your're using Windows OS and Etcher from https://etcher.io/, if you're using Unix/Linux (if you like do it via command line: https://codeyarns.com/2013/06/21/how-to-write-a-d...)
  5. When it's completed remove and put inside of raspberry pi card adapter.

Step 3: Plug & Configure

Connect raspbbery pi as shown on images.

  1. Plug USB OTG with raspberry pi and USB HUB
  2. Connect Mouse and Keyboard via USB HUB, connect HDMI with monitor
  3. Switch DC 5V 1A USB power(green led will flicker, if no please make sure that all above mentioned steps were done. If all steps ok and again raspberry not working please rewrite SD card image file).
  4. Pixel desktop will appear on monitor
  5. From start menu you can see that python already installed:
  6. Press Ctr+Alt+T, which will open linux terminal and type raspi-config
  7. You can change password and setup VNC ( to control remotely)

Add: you can attach cooler

Step 4: Connecting Servo Motor

First of all we need about 1kΩ resistor. It may protect the GPIO pin from unexpectedly high currents in the control signal, which could occur if a fault developed on the servo.

Servo motors wires: red (+), brown (ground) and orange (signal)

We can connect servo with raspberry GPIOs using three method:

1

Through jumper and breadboard connect:

  • orange with GPIO BCM 17 or 18
  • brown with GPIO GROUND(6)
  • and red with GPIO 5V power (2)

Conclusion: we are using power from raspberry pi zero which may unexpectedly reboot raspberry pi(theoretical yes, it's right, but practically I used this config method about one week and never had been fault)

2

Through jumper and breadboard connect:

  • the same methoid as above
  • brown with GPIO GROUND(6) and with external 5V 1A DC ground wire (if you want you can use op-am voltage regulator)
  • and red with + wire of external 5V 1A DC + wire

3

Through jumper and breadboard connect:

  • the same methoid as above
  • brown with GPIO GROUND(6) and with external 4-cell rechargable battery AA, 4.8 V (if you want you can use op-am voltage regulator with switcher) and red with with external 5V 1A DC + wire
  • and red with + wire of 4-cell AA 4.8v rechargable battery

Step 5: Programming and Controlling

We'll using wiringPi tool for gpio

Click to open

You can control it via VNC

Other remote access methods