It is the first time that I use a servo motor. I hear servo motors are often used for robots. DC motors torn round and round, but servo motors rotate only limited angle. They have different applications.
SG92R have 3 signal lines: 5V, GND, and control signal. 4 AAA battery should be connected to 5V signal. I connected the control signal to Raspberry Pi 2's PWM port. We can control rotate angle by using PWM port.
I used "softServo", which is one of wiringPi library, to control the servo motor. We can download wiringPi by using:
git clone git://git.drogon.net/wiringPi
Running ./build in wiringPi folder will make wiringPi library under /usr/local/lib folder. However, This library doesn't include softServo.c, which is required to control server motor. I have to change Makefile so that it build softServo.c too. wiringPi library have already exist in /usr/lib at NOOBS 1.4.2, so,
gcc -o test test.c -lwiringPi
cause an missing function error because it first search /usr/lib/libwiringPi.xx first. So, I use the following command:
gcc -o test test.c -L/usr/local/lib -lwiringPi
I run the command and the servo motor moved by 120 degree with Brrr-r-r sound.