00:01
In this question, we have to control a dc motor, stepper motor, and a servo motor using a raspberry pi.
00:08
So we have to write a python program for that.
00:13
So let's see the code for it.
00:15
We are in google colab.
00:18
Let's import some basic libraries.
00:24
This is how we will import the general purpose input output library of the raspberry pi and time of python.
00:34
First we will define the pin.
00:37
These are all the pins that our motors are connected to the raspberry pi board.
00:53
Next, we will define some state variables to handle the states.
01:02
Next, we will set up some general purpose input output operation pins.
01:10
So for that, we will use the function setmode setup that we get from gpio library.
01:20
Now, after that, we will create two variables for controlling the dc motor and servo motor.
01:34
After creating these variables, we will use gpio library to set the spin of both the motors.
01:50
After that, we will start the motor controls.
01:57
For that, we will create some functions startdcmotor, stopdcmotor, moveservoangle, and movesteppermotor.
02:08
So these four functions will control all the motors.
02:14
This is for dc motor start, stop, and this is for servo motor for its angle change, and this for stepper motor to step up a certain step every time.
02:27
So this is how we have used gpio library.
02:32
So in moveservotoangle motor, we will give angle as a parameter.
02:39
Then we will write this formula into duty cycle variable.
02:45
Then by using change duty cycle from servo motor, we will define the servo motor angle.
02:54
After that, we will move to a stepper motor using gpio pins.
02:59
We will set it to counterclockwise direction.
03:05
Then we will give it some delay...