Notifications
Clear all

Servo not working with Rapberry PI 4

4 Posts
2 Users
0 Likes
3,463 Views
 dax
(@dax)
Member
Joined: 4 years ago
Posts: 3
Topic starter  

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 4 years ago by dax

   
Quote
Topic Tags
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2035
 

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)
Member
Joined: 4 years ago
Posts: 3
Topic starter  

@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)
Member
Joined: 5 years ago
Posts: 2035
 

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