Skip to main content

Interfacing Raspberry Pi 3 B+ with Servo Motor ✨ (English & Marathi)

 💻 Introduction

A servo motor is widely used in robotics and automation projects. It allows precise control over rotation. In this tutorial, we will learn how to interface a servo motor with Raspberry Pi 3 B+ using Python.

What will you learn?

  • How a servo motor works
  • Wiring the servo with RPi 3 B+
  • Writing Python code to control the servo

🛠 Components Required

        Component Quantity
        Raspberry Pi 3 B+             1
        SG90 Servo Motor         1
        Jumper Wires         3
        External 5V Power Supply (Optional)         1


🛠 Circuit Diagram & Connection : 

Connect the servo motor to Raspberry Pi as follows:   

Servo Pin                                 Raspberry Pi pins
 VCC (Red)      5V  (Pin 2 or 4)
 GND (Black/Brown)      GND (Pin 6)
 Signal (Orange/Yellow)      GPIO 17 (Pin 11)

🔗 Ensure to use an external power supply for multiple servos to prevent overloading the Raspberry Pi.


💻 Python Code to Control Servo

import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.OUT)
servo = GPIO.PWM(17, 50)  # 50Hz PWM frequency
servo.start(0)

def set_angle(angle):
    duty = 2 + (angle / 18)
    servo.ChangeDutyCycle(duty)
    time.sleep(0.5)
    servo.ChangeDutyCycle(0)

try:
    while True:
        angle = int(input("Enter angle (0-180): "))
        set_angle(angle)
except KeyboardInterrupt:
    servo.stop()
    GPIO.cleanup()

🎉 Testing

  1. Run the script using:
    python3 servo.py
    
  2. Enter different angles (0-180°) and observe the servo movement!

🇮🇳 (मराठीत) Raspberry Pi 3 B+ आणि सर्व्हो मोटर इंटरफेसिंग

💻 परिचय

सर्व्हो मोटर ही अचूक कोन नियंत्रित करण्यासाठी वापरली जाते. या ट्युटोरियलमध्ये आपण Raspberry Pi 3 B+ सोबत सर्व्हो मोटर कशी जोडायची हे शिकू!


🛠 आवश्यक साहित्य

 घटक                                                 प्रमाण
Raspberry Pi 3 B+ 1
SG90 सर्व्हो मोटर 1
जम्पर वायर 3
बाह्य 5V पॉवर पुरवठा (पर्यायी) 1

🛠 वायरिंग डायग्राम आणि कनेक्शन

सर्व्हो पिन                                 Raspberry Pi सोबत कनेक्शन
VCC (Red) 5V (Pin 2 किंवा 4)
GND (Black/Brown) GND (Pin 6)
सिग्नल (Orange/Yellow) GPIO 17 (Pin 11)

💻 सर्व्हो नियंत्रित करण्यासाठी पायथन कोड

import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.OUT)
servo = GPIO.PWM(17, 50)  # 50Hz PWM frequency
servo.start(0)

def set_angle(angle):
    duty = 2 + (angle / 18)
    servo.ChangeDutyCycle(duty)
    time.sleep(0.5)
    servo.ChangeDutyCycle(0)

try:
    while True:
        angle = int(input("कोन प्रविष्ट करा (0-180): "))
        set_angle(angle)
except KeyboardInterrupt:
    servo.stop()
    GPIO.cleanup()

🎉 चाचणी

  1. खालील कमांड वापरून स्क्रिप्ट चालवा:
    python3 servo.py
    
  2. विविध कोन (0-180°) प्रविष्ट करा आणि सर्व्होचा प्रतिसाद पाहा!

🌟 निष्कर्ष (Conclusion)

आता तुम्ही Raspberry Pi 3 B+ वापरून सर्व्हो मोटर नियंत्रित करू शकता! 🚀


Stay tuned for more Raspberry Pi projects! 💡

Comments

Popular posts from this blog

IOT : GARDEN WATER SPRINKLER SYSTEM

IoT projects have gained immense popularity due to their ability to leverage the power of interconnected devices and data to create innovative solutions across various domains. IoT projects involve integrating sensors, actuators, and communication technologies to enable the seamless exchange of data between physical devices and the internet. These projects range from simple DIY experiments to complex industrial applications, each offering unique opportunities to transform our lives and improve efficiency. Whether it's creating a smart home automation system, monitoring environmental conditions, optimizing energy usage, or developing intelligent transportation systems, applications of IoT open up a world of possibilities for innovation and connectivity. By harnessing the potential of IoT, we can build intelligent and interconnected systems that revolutionize industries, enhance daily life, and pave the way for a more efficient and sustainable future. In this project we will be using...

POWER BI - THE ARCHITECTURE

Power BI Architecture: A Comprehensive Guide to Building Effective Data Analytics Solutions     Understanding Power BI Architecture: Power BI's architecture comprises four main components, each playing a pivotal role in the data analytics process: Data Sources:   Power BI connects to a wide range of data sources, including databases, cloud services, Excel files, web services, and more. This versatility enables organizations to consolidate their data from various systems into a single dashboard. Data Transformation:   Once the data is sourced, it undergoes transformation and cleaning processes to make it suitable for analysis. Power BI's Power Query Editor provides a user-friendly interface to manipulate, filter, and shape data according to specific requirements. Data Model:   The heart of Power BI's architecture lies in its data model, whic...

TOUCH PLATE BASED DOOR BELL

Title:  Touch plate based door bell  Circuit:  Components: IC 555 Resistors: 1 M, 100k, 330 ohms Transistor: BC547  PN2222A Capacitor: 10n 1 Copper plate : as touch plate. A 6v battery An LED / Ic UM66 Description: This is the simple circuit for touch plate based security system. In this project what basically done is, circuit detects stray voltages produced by mains voltage and electrostatic built  up in the room.If sufficient static voltage is detected by the plate then chip will charge up. Transistor BC 547 or PN2222A is used basically to increase the sensitivity.In place of led just connect IC um 66(melody IC). Applications: In homes, of course. This can be specially used in places like hospitals, when patients need to call doctor by himself.