Notifications
Clear all

Servo not working with Rapberry PI 4  

  RSS

dax
 dax
(@dax)
New Member
Joined: 1 year ago
Posts: 3
2019-11-06 4:53 pm  

Hello,

I am trying to control Tower Pro MG995 servo with the Raspberry Pi 4B. I am powering the servo with a 5V power supply and when I connect the servo to GPIO 12 or GPIO 18, it doesn't move but when I connect it to GPIO13 or GPIO19, it rotates continuously in one direction. I've tested the servo on an Arduino using the SWEEP example and it works fine there. Is there any problem with my GPIO pins? Please help.

Here's the code that I'm running on the PI

from gpiozero import AngularServo
from time import sleep

servo=AngularServo(12,min_angle=0,max_angle=180)

while True:
a = float(input("Enter Angle "))
print(type(a))
servo.angle = a
sleep(1)

 

Thanks

This topic was modified 1 year ago by dax

Quote
Topic Tags
robotBuilder
(@robotbuilder)
Honorable Member
Joined: 1 year ago
Posts: 526
2019-11-06 5:37 pm  

May I ask where the code came from?

I notice the servo you are using can come with a 360 degree rotation.

 


ReplyQuote
dax
 dax
(@dax)
New Member
Joined: 1 year ago
Posts: 3
2019-11-06 7:13 pm  

@casey

I wrote the code myself and now I see that the servo rotates 360 degrees at GPIO 12, 13 and 19 but it has no response at GPIO 18


ReplyQuote
robotBuilder
(@robotbuilder)
Honorable Member
Joined: 1 year ago
Posts: 526
2019-11-07 1:04 am  

I would try some other code to see if it acts like a normal servo and what its rotation range is?

https://tutorials-raspberrypi.com/raspberry-pi-servo-motor-control/

 


ReplyQuote