Head Rotation (Neck)
Head rotation with an MG996R servo. Implement head rotation driven by a controller, by random motion, and by image processing.
Roadmap
Section titled “Roadmap”This page is the guide for the 'Head Rotation (Neck)' node on the roadmap below.
This guide assumes you have completed the smabo-esp32 setup.
Overview
Section titled “Overview”This page explains the Head Rotation (Neck) feature.
Specifically, you will implement:
-
Manual controller control
-
Random motion control
-
Image-recognition-based head tracking
Required Parts
Section titled “Required Parts”In addition to the parts from smabo-esp32, you need the following.
| Part | Example (Japanese shop) | Notes |
|---|---|---|
| MG996R | link | Compatible alternatives OK, but if the horn size differs from the genuine part, the printed parts will not fit well. In that case, you may need to trim the horn or modify the 3D model. |
3D Printing Parts
Section titled “3D Printing Parts”Print the newly added parts on your 3D printer.
Because slicer software varies by printer model, only key points are noted here rather than step-by-step slicer instructions.
Print the following parts oriented as shown in the images.
-
smabo-hardware/stl/pan/mg996r/pan_adapter.stl

-
smabo-hardware/stl/pan/mg996r/pan_plate_top.stl

-
smabo-hardware/stl/pan/mg996r/pan_stand_left.stl

-
smabo-hardware/stl/pan/mg996r/pan_stand_right.stl

Assembly
Section titled “Assembly”Assemble the required parts as shown in the video below.
Note: the video also includes parts printed in previous steps.
Wiring
Section titled “Wiring”Wire according to the tables below.
In the tables below, "Point A" and "Point B" are directly connected in the circuit.
Battery
Section titled “Battery”| Point A | Point B | Notes |
|---|---|---|
| Battery box (+) | Breadboard + rail (right side) | From here on, the right side is the 6 V rail |
| Battery box (-) | Breadboard - rail | - |
| Point A | Point B | Notes |
|---|---|---|
| ESP32 3.3V | Breadboard + rail (left side) | From here on, the left side is the 3.3 V rail |
| ESP32 GND | Breadboard - rail | - |
PCA9685
Section titled “PCA9685”| Point A | Point B | Notes |
|---|---|---|
| PCA9685 V+ | Breadboard + rail (right side) | Servo power (6 V) |
| PCA9685 VCC | Breadboard + rail (left side) | Logic power (3.3 V); SDA and SCL also use this voltage |
| PCA9685 SDA | ESP32 pin set in config.json i2c/sda |
Default pins: - config.esp32-classic.json: GPIO 18 - config.esp32s3-devkitc1.json: GPIO 11 |
| PCA9685 SCL | ESP32 pin set in config.json i2c/scl |
Default pins: - config.esp32-classic.json: GPIO 5 - config.esp32s3-devkitc1.json: GPIO 10 |
| PCA9685 GND | Breadboard - rail | - |
MG996R
Section titled “MG996R”| Point A | Point B | Notes |
|---|---|---|
| MG996R (neck) connector | PCA9685 channel 2 | Insert so the brown wire (GND) is on the PCA9685's GND side |
The wiring diagram for the ESP32-DevKitC (with the defaults in config.esp32-classic.json) is shown below.
Note: with the default settings, connect the neck servo to channel=2.

Finished Result
Section titled “Finished Result”The completed robot looks like this.

Operation
Section titled “Operation”Startup Procedure
Section titled “Startup Procedure”Follow the startup procedure here.
Then open the 'Config' tab in smabo-web.
Servo Settings
Section titled “Servo Settings”Servo settings can be changed in the 'Modes/servos' section of the 'Config' tab in smabo-web.
Here, enable:
- 'head_pan'

Manual Control
Section titled “Manual Control”Steps for manual controller control.
In the 'Config' tab → 'Modes/servos', for head_pan, set:
- 'mode' to 'manual'

Adjust the servo angle in the 'Servo' tab to rotate smabo left and right.
Random Control
Section titled “Random Control”Steps for random motion control.
In the 'Config' tab → 'Modes/servos', for head_pan, set:
- 'mode' to 'random'
- 'group' to 'neck'

After a moment, smabo will turn left/right at random intervals.
Image-Processing Control
Section titled “Image-Processing Control”Steps for image-recognition-based control.
In the 'Config' tab → 'Modes/servos', set head_pan's:
- 'mode' to 'manual'

In the 'Vision' tab → 'Detection':
- Enable 'Enabled', and
- Select your detection mode (e.g., color mode to track a blue object)

In 'Behaviors':
- Enable 'Servo follow', and set
- 'Pan joint' to 'head_pan'
- 'Pan direction' to 'reversed (−1)'

After configuring, place the target object in front of the phone camera. smabo will rotate its head to track the object.
This is a terminal node on the roadmap.
To explore other features, pick another page from the roadmap.