DC Motor Speed Controlling in Raspberry pi
You want to control the speed of a DC motor using your Raspberry Pi. Today I show you How Controlling Speed DC Motor Raspberry pi Step by step in complete Process.
Components Required
This book will help you to gain more knowledge of Raspberry pi Software and Hardware Problems and Solutions
Raspberry Pi Cookbook
Circuit diagram Controlling Speed DC Motor Raspberry :
shows how you can wire this BC Motor using a MOSFET, Diode, Power and male-to-female jumper leadsControlling a high-power motor Raspberry pi
The diode across the motor to prevent voltage spikes from damaging the transistor or even the Raspberry Pi. The 1N4001 is a suitable diode for this. The diode has a stripe at one end, so make sure that this is facing the right way.
In this case, you will use a high-power type of transistor called a metal– oxide–semiconductor field-effect transistor (MOSFET), which costs less than a dollar but can handle loads up to 30 amps—many times more than is required for the high-power LEDs. The MOSFET used is an FQP30N06L
And I show how you can connect a MOSFET on a breadboard. Make sure that you correctly identify the positive and negative supply leads for the LED module.
Code Controlling Speed DC Motor Raspberry :
from tkinter import * import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) GPIO.setup(18, GPIO.OUT) pwm = GPIO.PWM(18, 500) pwm.start(100) class App: def __init__(self, master): frame = Frame(master) frame.pack() scale = Scale(frame, from_=0, to=100, orient=HORIZONTAL, command=self.update) scale.grid(row=0) def update(self, duty): pwm.ChangeDutyCycle(float(duty)) root = Tk() root.wm_title('PWM Power Control') app = App(root) root.geometry("200x50+0+0") root.mainloop()When you run this code You can see like this interface and you can control your DC Motor speed
No comments