My new SG90 Micro Servo motors have arrived, so I can begin to work.
1. Mechanics
I would like to make Balambér able to turn around his had. So I designed a small attachment that connects the SG90's "shaft' with the empty neck of Balambér. The small 3D printed part makes its job pretty well. (I will share the STL files later on.)
2. Electronics
The servos ask for PWM but the Raspberry Pi has only one (or two) of these outputs. So I use the "poor man's PWM": the PigPio.
2 .1. Cables and connections
The outputs of the Raspberry Pi is very week, so I feed the servo with 5V from external source. (Do not forget to connect your external source's ground to one of the Raspberry Pi's ground.) Then I connected the servo's PWM line (orange) to the RPi's GPIO 23 (pin 16). (Yes, you can choose any of the normal GPIO-s.)
2. 2. Software
I downloaded and installed the PigPio library as it was told on its website. Then I had to begin with:
sudo pigpiod
I made a very simple but working python example how to turn his head around.
import time
import pigpio
GPIO = 23
pi = pigpio.pi()
for x in xrange(50,250):
pi.set_servo_pulsewidth(GPIO, x * 10)
time.sleep(0.2)
pass
pi.set_servo_pulsewidth(GPIO, 0)
Please send me a message if you find problems with this code.
And now, let's work on the head-bang servo. :D
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.