Python GUI for Arduino Servo Motor Control

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video a python gui is designed to control a servo motor interface with arduino nano a block diagram of the implemented system is shown here we have servomotor sg90 interfaced with arduino through digital pin d8 and we have two leds connected to pins d3 and d5 a python gui is designed in such a way so as to control the rotation of the servo motor either clockwise or counterclockwise the gui includes a slider to give us the rotation angle from minimum 0 degrees to 180 degrees and we have an input field here which gives us the speed of rotation one is the slowest five is the fastest and we have two push buttons this button here will rotate counterclockwise and this button will rotate clockwise and we have the about button to give us more information about the software and the quit to close the application and now for a quick demonstration during counter-clockwise rotation blue led is on and during clockwise rotation red led is on a look at the python code we need to import these modules into the program and here we initialize the arduino nano board indicating that the board is connected to serial port com3 and here we are indicating that digital pin 8 of the arduino has a servo connected to it now we look at the gui design part of the code using the widget tk we create the window and give it a name servomotor and the dimensions of the window is 290 pixels by 150. next using the scale widget we create the slider which will have a value between 0 and 180 horizontal orientation and the location is column two row one and then we will add a text here using the label widget and the location of this text is column three row one next using the entry widget we create this input field located at column two row two and the instruction text here is located at column three row two we have four buttons which are created using the button widget the counterclockwise rotate button is located at column two row four one clicked it will call this function counterclockwise we set the rotation angle and the speed and then we click on the counterclockwise rotate button the program will jump to this function definition counterclockwise where the blue led will be on and the red will be off and then we will get the rotation angle from this slide input and convert it into integers so it will be a value between 0 and 180 degrees and then we get the rotation speed which is a value between 1 and 5 and save it into this variable and then we call this function in order to convert the speed into an appropriate time delay and save it in this variable function delay select will receive the speed and using the match structure and based on the case value for speed 1 the delay is 0.1 seconds for speed 2 it's 0.09 and suppose speed 5 it's 0.01 seconds and then we return this delay value to the calling function once we have the rotational angle and the delay associated with the input speed we can use this for loop so that we can cover the angles from 0 to the rotational angle input here and then inside the loop we will send this angle to pin 8 where the servo motor is connected and then we apply the delay and we continue with this process until the rotation is complete and then we turn off the blue led in a similar fashion when we click on the clockwise rotate button the program will jump to this function definition clockwise where the blue led will be off and the red will be on and this part of the code will rotate the servo motor based of the input angle and the speed and at the end of the rotation the red led will be turned off clicking the about button will bring the message box and the program will jump to this function definition and using the module message box and function show info the about will appear as the title of the message box and then the text to be displayed on inside the message box finally clicking on the quit button the program will jump to quit app function definition where this statement will disconnect the arduino board from the python application and also this statement will close the application in a future video a python gui will be designed to control a dc motor thank you for watching
Info
Channel: Anas Kuzechie
Views: 10,023
Rating: undefined out of 5
Keywords:
Id: 1GShLwGMMFo
Channel Id: undefined
Length: 6min 55sec (415 seconds)
Published: Mon Aug 22 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.