Joy-it COM-MOTOR05 Manual Download Page 4

4. APPLICATION WITH A RASPBERRY PI

Initially, connect the motor with your Raspberry Pi like shown in the 

following connection diagram.

Since the motor is connected, you can transmit the following code 

examples to your Raspberry Pi and test their functions.

In general applies:

The motor is controlled by the command 

pwm.ChangeDutyCycle().

The 

value between the brackets, can be among 2.5 and 12.5. If the value is 

beneath a value of 7.5, the motor rotates in one direction. If the value is 

above a value of 7.5, the motor rotates in the other direction. The further 

away  (or rather higher and lower) the value is from 7.5, depends on the 

speed in which the servomotor is rotating.

If the value is set on 7.5, the motor stops. 

You can modify and edit the code examples according to your wishes as a 

matter of course.

Create now a data file with the following command:

sudo nano servo.py

Now enter the following code example into the editor. After that you can 

save the file with the key combination of 

STRG+O

 and you confirm it with 

Enter

. You can leave the editor with the key combination 

STRG+X

.

Reviews: