I don’t usually post here in english. But I have the feeling that others might find this useful, so.
OK, I was looking for a DVB-T receiver, I would like to pick up transponder signals from passing airplanes. I went to Pimoroni, and found this: Cooooool!
Bought it, waited for it. Got it. How to control it?
Well, it uses two small servomotors. Those take a PWM-signal. And my Raspberry Pi have only one pin that can handle that.
Luckily other people have wanted to play with this. Richard Hirst have written a kernelplugin to Rasbian, that allows us to add servo control. The plugin is called ServoBlast. And I got it on my Raspberry in this manner:
First I installed Git:
sudo apt-get install git
Then I cloned the servoblaster code
git clone git://github.com/richardghirst/PiBits.git
Got into the directory:
cd PiBits/ServoBlaster
Cursed a lot, and finally found my way into the right directory:
cd user
Ran the make commando:
sudo make install
And that was it! I’ll have to talk to my husband if I want to understand what actually happened. But now I was actually able to control the servos. How did I know that? Well, there is a hardware side as well.
The servos requires 5V, and although the Pi have a 5V pin, I ran it from an Arduino. There are two cables on the assembly. One for each motor. The red lead on both is connected to 5V from the Arduino. The browns to ground. And the yellow ones, which is the data-line, to pin 7 and 11 on the Pi. One of the ground pins on the Pi was connected to the Arduino.
And now, all I have to do write this on the commandline:
sudo echo 1=120 -> /dev/servoblaster
And the servo connected to pin 11 will move. Neato.
Heres a litte Python script to control the two servos graphically:
from subprocess import call
from tkinter import *
master = Tk()
def getSlider(event):
a = “echo 1=”+str(SliderV.get())+” > /dev/servoblaster”
b = “echo 0=”+str(SliderH.get())+” > /dev/servoblaster”
call ([a], shell=True)
call ([b], shell=True)
print(SliderH.get())
SliderH = Scale(master, from_=30, to=250, orient=HORIZONTAL, command=getSlider)
SliderV = Scale(master, from_=30, to=250, orient=VERTICAL, command=getSlider)
SliderH.set(0)
SliderH.pack()
SliderV.set(0)
SliderV.pack()
mainloop()
Adjust the “from” and “to” numbers to suit your servos.
Done!