connect@howdiyworld.com
|

Servo Motor Real time

BLOCK DIAGRAM

Procedure

  1. Servo Motor
  2. Connections
  3. Program
  4. Output

Procedure

Servo Motor

A servo motor is an electrical device which can push or rotate an object with great precision. If you want to rotate and object at some specific angles or distance, then you use servo motor. It is just made up of simple motor which run through servo mechanism.

Connections

  • Connect Servo Motor’s VCC to 2nd pin
  • Connect Servo Motor’s Ground (GND) to 6th pin
  • Connect Servo Motor’s PWM to 7th

Python Program

import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BOARD)

GPIO.setup(7, GPIO.OUT)

p = GPIO.PWM(7, 50)
def get_input(a):
b=a
p.start(2.5)
a=a/14.4
p.ChangeDutyCycle(a) # turn towards Real Data degree
time.sleep(1) # sleep 1 second
print(" deg:",b)
p.stop()
GPIO.cleanup()

Output

Here you can give an input in teams of degree, and then click set button servo motor will rotate give degree(ex:45,90,…).

Social media & sharing icons powered by UltimatelySocial
Facebook
Twitter
YouTube
LinkedIn
Instagram