النص الكامل للفيديو
In this course, you will learn to build computer vision projects with Arduino. The course combines computer vision, deep learning, and Arduino. Ulas Alaka will teach you to build two projects. The first project will control an LCD display using your facial movements leveraging deep learning and powerful tools like media pipe to detect and interpret facial features. In the second project, you will learn to control robotic arm using computer vision. The course covers topics like serial communication between Python and Arduino, face detection using landmarks, and practical applications with LCD displays and servo motors. You'll gain skills in image processing with Open CV. So, get ready to explore advanced computer vision applications. Nowadays, computer vision and deep learning topics are very popular. Would you consider making an advanced project by taking advantage of these issues? My name is Ilma Alaja and welcome to the introduction video of my advanced computer vision project with Arduino course. With the course, we will detect our facial expressions and automatically print our facial expressions on our SED screen according to our expressions. If you want to do advanced computer vision project, this course is for you. can't wait to see you among us already. Let's get started without wasting any time. Yes, my dear friends, in this lesson we will have information about the materials we will use in our course. First of all, the first material we will use is Arduino Uno. We will provide CED display control according to the signals coming with Arduino Uno. Our second material is an I2C supported acid display. With this screen, we will print out on our acet screen. The other material we will use is the webcam. With the help of the webcam, we will learn our facial expressions instantly and add meaning to what we have learned. And of course, cable is required to connect our Arduino board to the computer. Yes, my dear friend, this is how our materials are in general. So now, let's start our course without wasting time and realize our advanced project. In this lesson, we will see how we can install Python to our computer. First, let's open Google and write Python and let's press enter. As you can see, Python's official site is available. Now, let's open it. And here as you can see there is download section. Let's open it. And here Python version 3.9.7 is available. Let's download Python. click hide. And here as you can see it's downloaded. Let's open it. Since have installed it before encountered screen like this. For this reason, will choose customized installation. And here, as you can see, optional features is here. And will click next. And here, as you can see, there is advanced options. will leave it in default format. So, let's hit the install button directly. click install. As you can see, Python is installing. Let's continue when we are done. As you can see, we have successfully installed Python. Let's click close. Now, let's write Python in the search section of Windows. click search button and write here Python. click this app. Python 3.9. am choosing this. And here now, let's write print and open parentheses and close parenthesis. And between parentheses create double quotes and between double quotes will write hello world and press enter. As you can see we have successfully installed Python. In this lesson we have seen the Python installation. Let's continue with other lessons now. Hi, in this lesson you can have information about how we can install the Pychime IDE. Pychime IDE is an environment that allows us to write our Python codes easily. We will write and run codes in Python lessons throughout this IDE. So let's get started. First of all, let's type pychime into Google and press enter. will write PyCharm here and press enter. As you can see it says download PyCharm here. Let's click this. And here it is available in paid and free version. We will use free version. So am using community version because it's free. So let's click community download. am choosing the community one and click hide and look it started. Let's continue when it's done. All right my friend the downloading is over. Let's click this. And here is the setup screen. As you can see click next. This is the destination folder. Whatever you want. You can use any destination folder. will choose default. So click next. So as you can see there are some options. will choose the create desktop shortcut and update pet variable. So click PyCharm community edition and also add bin folder to the pad and then click next and click install. It's installing. When it finished we will continue. Yes my friend the installation is complete. Now we need to restart our computer. will choose to reboot manually but you can restart your computer by selecting reboot now. So click want to manually reboot later and click finish. So let's reboot our computer. All right my friend rebooted my PC and as you can see here there is PyCharm IDE app and click this. This is the user agreement. confirm that and click continue. And here as you can see this is our PyCharm IDE screen. So let's learn PyCharm IDE. If click new project button the PyCharm IDE start new project. Let's click this. And here as you can see there is location section and this Python project 5 is our project name. If you want to rename your project name, you can change here. For example, will change my project name. Let's write here. Hello. And as you can see, there is base interpreter. This is very important because we will run our Python code. And this is the part that will run our code. If you want to use all Python versions, you can change here. But if we use Python 3.9, it will be fine for us. So click Python 3.9.x and as you can see here there is create button in the lower right corner. Let's click this. So if click this my project will be creating. Yes my friend as you can see our project has been created. And here is our project name which is hello. So let's continue. Let's click close and move to your project folder. And let's right click and move to new and move to Python file. And here we can create our own Python file if we follow these steps. Now let's name our Python file. For example, first project and press enter. And here as you can see our Python file has been created. Now let's come here and write and open parentheses and close parentheses and between parentheses write double quote and write here for example IMAS. So when we do something like this we use the standard output function in Python. And if press the right button of my mouse and as you can see here is the option to run it. If select run first project, my Python file will run. Let's click this. And as you can see here, we run our first code. Yes, my dear friend, we have installed our Pychim IDE in this lesson. Of course, these sections can be boring. However, we will have lot of fun writing our project codes once we have the necessary setups done. Let's continue with our other installations. Now, Yes, in this lesson we will learn how to install our OpenCV module in PyCharm IDE. As you can see there is terminal section here. Let's select this. And now we have to write some codes to our terminal section. Let's write will write pip put space and then we have to write install put space and also we have to write open cv minus python and now let's press enter as you can see here we have successfully installed our open cv module Now simply import in your Python program in which you want to use image processing functions. So let's check it. Move to your project folder and let's right click move to new and let's create new Python file. And let's say here for example test and press enter. And then we have to import open CV module. Let's write import with space CV2. If we do like this, we can define our OpenCV module. And to check if Open CV is correctly installed, let's check it. Move to new line and let's write print function open parentheses and let's say CV2 dot version and also put underscores. And now let's run our code. As you can see here, we have successfully reached our OpenCV version. So the installation is successfully. Yes, we installed our OpenCV module in this lesson. Let's continue with our next lesson. Yes my dear friends in this lesson we will install our media pipe module. So why are we going to use this module? Because with this module we will reach the landmarks of our face and learn our guests according to the coordinates of each of our facial lines. As you know when we smile our lip movements are at different points. Of course this also applies in sad and normal situations. For this reason we will perform these operations together with the media pipe module. So let's move on to the installation. Now let's open our Pychime IDE and come to the terminal section and let's write here pip put space install media pipe and also let's press enter. And as you can see here we have successfully installed our media pipe module. So now let's continue with our next lesson. Yes my dear friends in this lesson we will have information about Arduino IDE installation. First of all let's write Arduino to Google. So will write here Arduino and also press enter. And now as you can see Arduino's official website is available. So let's click that now which name is also Arduino.cc. So let's click this. And as you can see here there is software section here. So let's click this. And as you can see there is version 1.8.16 available. We will choose the this download option Windows win 7 and also newer because we will learn the basic Arduino knowledge to ro of Windows and also if you are using different operation system you can also choose different download option for your operation system. Now let's come and download this. will download Win 7 and newer. So let's click just download. And as you can see the installation was started. Yes, the download is complete. Now let's come and open it. And as you can see there is license agreement. So let's click agree. And also we will install all of these components. So let's click next. And here is the pet specification. will leave that as default. So click install button. Yes, the installation process is complete. So, let's click close. As you can see, the Arduino app is here. Now, let's move on to our next lesson and learn the Arduino IDE interface. Yes, my dear friend. In this lesson, we will learn about the interface of Arduino IDE. First of all, as you can see here, there is the void setup part. The codes of the Arduino board are written in or C++. The structure that starts with void here is function. The void setup section allows us to set up our Arduino codes. And here the codes run once and the loop part you see here is our function that repeats the given commands continuously. And here we will perform operations such as motor control, lamp control and also as you can see here there are parts that verify and upload. The verify here checks the code we write. If it is upload it uploads the codes we wrote to our Arduino board. When we come to the tools tab, so as you can see here, click this. We learned the USB port to which our Arduino board is connected. As you can see here, here is the post section. Yes, my dear friend, this is our interface in general. Let's move on to our next lesson. Yes, my dear friends. In this section, we will learn how we can control our LCD screen with Arduino. So, let's get started. First, let's take closer look at our acet screen. This is an acid screen that you have seen in my hand. Our SED screen consists of two rows and 16 columns. Also, we need to use four different lines to code our SED screen. Two of these lines are power lines. That is the G&D and 5V pins. The other two lines are the I2C line. Signal pins on these lines. Normally we have to do lot of wiring but thanks to the I2C module this wiring is considerably reduced. The SDA pin allows us to transfer data and also SCL is the clock rate. So the Sccl pin allows us to transfer all data synchronously. Yes my dear friends we have entered our LCD secret section with short introduction content. So now let's move on to our other lessons and check our acid screen with Arduino. Well, yes my dear friends in this lesson we will learn about ITC. It's especially important that we know the structure of the I2C protocol because there is an I2C module on the SD screen. We will use I2C is serial communication protocol. Communication takes place over two lines. These are SD and Sccl. Both buses are birectional that is data can be sent and received. Communication with I2C is also based on the master and the slave relationship. For example, while our Arduino board is master, our SED screen is slave and we control the slave throughout the master. In addition, each device used in the I2C protocol has its own address. For example, like 0x27. We will use an address like this when using our SD screen. In this way, we will prevent data from being lost while transferring our data. Finally, the communication between master of slave is of bit type. Since the microprocessor on our Arduino board is 8 bit, the data is transferred 8 by one. Yes, my dear friend. In this lesson, wanted to inform you about I2C. So now, let's continue with our next lesson. Yes, my dear friends. In this lesson, we will add our SED display library to Ardino IDE, which is necessary for us to use our LCD display. So, let's get started. First of all, we need to download our necessary files as zip files on GitHub. Now, let's come and download it as dozip file from here. So let's select this code section and let's select the download zip and as you can see here we have successfully downloaded this zip file and as you can see here is our zip file. By the way will add this website to the this video source section. So let's continue. Now we have to open the Arduino IDE. So let's open the Arduino and here is the Arduino IDE. So if you want to add any zip file to the Arduino IDE, we have to move to the sketch section. And as you can see here is the same as include library. So let's move to this. And as you can see here, it says add.zip library. So now let's select this and also we have to add our Arduino liquid crystal I2C library master and also let's move to the desktop section and let's select this zip file and also click the open button and as you can see here we have successfully added to our library. So let's check it out now. Open the sketch section and move to the include library. And as you can see here is the our library. So now let's select this. And as you can see here we have successfully included our library. So now let's verify our code and let's write here for example as sd. So now let's save this file. And as you can see here, compiling is done. So we have successfully added it. All right, my friend. In this lesson, we learned how to add our library to the Arduino IDE. So let's move on to our next lesson. Yes, my dear friend. In this lesson, we will learn our connection diagram so that we can control our LCD screen. As you know in our previous lessons told you the G&D line of the G&D line. said that the VCC line should be connected to the 5V line. For this reason let's connect our G&D that is our ground line to the G&D line on our Arduino board. Let's connect the VCC that is the power line to the 5V line on our Arduino board. Our other lines are SDA and Sccl. Since we will use our Arduino Uno board, we need to use I2C lines especially set for our board. SDA pin is set as analog 4 pin on Arduino Uno board. For this reason, we will connect the SDA pin on our LCD screen to the A4 line. Finally, there is the connection of our SL pin. SL pin is set as analog 5 pin on our Arduino board. For this reason, we will connect the SL pin on our LCD screen to the A5 line. Yes, our connection diagram is up to here. Let's move on to our next lesson and print text on our LCD screen. Yes, my dear friends. In this lesson, we will write the necessary codes so that we can print text on our SD screen. As you know, we made our connection in our previous lesson. Now let's open the Arduino IDE. So let's collect the Arduino app. And as you can see here is the our source code section. And also as you know we added our library. So our library is liquid crystal I2C. Let's come and include our library. So let's write here include liquid crystal underscores I2Ch and as you remember here is the our I2C asset screen library. So let's continue. If you want to use our SD screen the action we need to do is to call class in our library. Our class name and library name are the same. So let's come here and write liquid crystal underscores I2C and of course we need to give our class name. So let's put space and for example let's write my underscores acid here is the our supreme name and also we need to open parentheses and let's close the parentheses and also do not forget to use semicolon and then let's move inside of our parenthesis. We will enter three different parameters inside of our parenthesis or my LCD parenthesis. Our first parameter will be the address of our LCD screen. In general, the address of I2C supported SD screen is 0 27. So that is the our screen address and then let's put comma and also we will enter the second parameter. Our second parameter is the number of columns. As you know my acid secret columns is 16. So will write here 16. And of course our last parameter is our row count. As you know our row number is two. Therefore let's define the value two. After introducing our SD screen we need to start our screen in the setup function. Our required method to start our SD screen is the begging method. Before we write our code inside of our setup function, let's delete the our comment and also let's call our sedreme variable. So our variable name is my underscores sedd and also put dot and let's write here began and also open and close parentheses and let's put semicolon. If you do something like this, we will have started our SD screen. So now let's continue. What we need to do now is to specify the position of the text. We will print before printing the text on our SD screen. And also this is done with the set cursor command. So now let's move inside of our loop function. And let's write here my underscores sedd. Cursor and also open and close parentheses. And let's put semicolon. And let's move inside of our parentheses. We will enter the two different parameters here. Our first parameter will be our number of columns and also our second parameters will be number of rows. So if write here 0 comm, 0, this is the our beginning point of our SD screen. And also let's move to new line. And now let's write the text. If you want to write any text on our SED screen, we have to use print function. So let's write here. Firstly, let's call our SD secret variable. So our SD variable name is my underscores sedd and also put dot and let's call our print function and also open and close parentheses and let's put semicolon. And let's move inside of our parentheses. Let's create double quotes here. And let's move inside of our double quotes. For example, let's write hello world. All right, we are done. So now let's verify our code and also let's save our file. For example, let's write here my sedd and also let's click the save button. And as you can see here, the compiling is done. So now let's upload our code to the Arduino. And as you can see here, the uploading is done. So now will share my camera with you. And as you can see here, we have successfully printed text on the SD screen. So now let's continue with our next lesson. Yes, my dear friend. In this lesson, we will learn how to clean our SD screen. In order to perform this operation, we need to learn new method. The name of this method is clear. We can clear our SED screen with the clear method. So, let's get started. First of all, let's include our acid screen library. So, let's move to the top and let's include our liquid crystal i2c.h library. And then let's move to new line. Call our liquid crystal I2C class. So will write here liquid crystal I2C. And also we have to set name here. So put space and let the class name be for example LCD and also open and close parenthesis and put semicolon. And let's move inside of our parentheses. First of all, we have to define our LCD screen address as 0x 27 and also put comma and the second parameter will be our column number. So our column number is 16 and also we have to define last parameter. Our last parameter will be our row number. So our row number is two. If you do something like this, we have successfully introduced our SD screen. And then let's move inside of our setup function and let's start our SD screen. So let's write here LCD dot begin and also open and close parentheses and put semicolon. And then let's move to the loop function. Let's let this comment. All right, let's do an example here. For example, let's print hello for 1 second on our SD screen. Then let's delay it. Then let's print CU for 1 second and also delete it again. So now let's move to the loop function here and also we have to call our set cursor function. So let's write here sd do set cursor and also open and close parentheses and put semicolon and let's move inside of our parenthesis. The first parameter will be our column number. So will enter zero because will output at my starting position. So my starting position is 0 comma 0. That's why we define as 0 comma 0. And also let's move to new line and let's call our print function because we will print hello on our LCD screen. So let's write here LCD. and also open and close parentheses and put semicolon and move inside of our parentheses. Let's create double quotes and let's write here hello and then let's move to new line and let's call our delay function because we will keep it on the screen for 1 second. So that's why we call our delay function. So let's write here delay and open and close parenthesis and put semicolon and move inside of our parenthesis. Let's define 1,00 to inside of our parentheses and also we will learn new function here and also we can say method two. So our new function is clear. So if you want to use clear function firstly we will call our sedd variable name. So my sedd variable name is sedd and then put dot and let's write here clear and open and close parentheses and put semicolon. If you do something like this we will clean or acid the screen. So let's continue. So now let's move to new line and call our print function again because we will print cu that's why we call again print function. So let's write here scd.print print open and close parentheses and put semicolon and move inside of our parentheses. Let's create double quotes and let's write here cu and then let's call our delay function again because we will keep it on the screen for 1 second. So let's write here delay open and close parentheses and put semicolon and let's define value 1,00 and then let's clear screen again. So let's write here LCD clear open and close parentheses and put semicolon. All right my friend, we are done. So now let's verify our code. So let's write here clear and let's save this file. And as you can see here, the compiling is done. So now let's upload our code. All right, my friends, we are done. So now will share my camera with you. As you can see, we were able to successfully clear our screen and print what we want to within 1 second. All right, my friend. In this lesson, we learned how to clean our LCD screen. So now let's move on to our next lesson. Yes, my dear friends, in this lesson we will learn how to create our own spacious characters. First of all, each text field on our SD screen consists of five columns and eight rows. We can manipulate these columns and rows and create special characters. Let's find out how we can do it now. So let's get started. Firstly, we will perform each operation over the byte data type. And as you can see here is the byte array. And also there is web page we can use here. will add this web page to the resources section. If you want to create special character, we have to choose our character from the green area you see here. So here is the green area. If choose any squares, as you can see our data type is changing. So let's make smiley face now. So here is clear button. Let's click this and also let's choose two eyes and also smiley face. And as you can see here is our special characters. And as you can see here is the bite type variable. So now let's copy this and then let's open the Arduino IDE and also let's move to the top and let's paste it here. So here is the our special character and also let's include our I2C acid screen library. So let's write included liquid crystal underscores I2C.h and also let's call our liquid crystal class. So will copy this and let's paste it here. And also let's define name to our class. For example, let's set it as sd and also open and close parenthesis. And let's put semicolon. And let's move inside of our parentheses. As you remember our first parameter will be our acid screen address. So my acid screen address is 0x27 and put comma. And our second parameter will be the our number of columns. So will define as 16. And also the third parameter will be the number of rows. So let's set it as value two. And also let's move to the white setup function. Let's delete this comment. And also let's call our begging function. So will write LCD. Begin. And also open and close parentheses and put semicolon. And then we will learn new function here and also we can call it as method. So our new function name is create char. Let's call our create jar method LCD dot create char and also open and close parentheses and then let's put semicolon and let's move inside of our parentheses. We will enter two different parameters here. Our first parameter will be the ID number. So thanks to this ID number we will able to print our special character. For example, let's define as value zero and also put comma. And our second parameter will be our byte variable name. So our byte variable name is custom chart. So let's write here custom chart. And also let's move to new line and let's call our set cursor function. So let's write here sd do set cursor and also open and close parentheses and put semicolon and let's move inside of parentheses. Let's define as beginning point. So 0 comma 0 and then let's move to new line and we will learn new function here too. Our function name is write function. With this function, we can show the data in our ID number on our SED screen. So let's write here SD dot write open and close parentheses and also put semicolon. And let's move inside of our parenthesis. We will define one parameter here. So the parameter will be the ID number. As you remember our ID number is zero. So will write here zero. If you do something like this, we get the result we want. So now let's verify our code. Let the name be for example char. And also let's save this file. And as you can see here, we didn't get any error. So now let's upload our code to the Arduino board. All right, we are done. So now will share my camera with you. And as you can see here, we have successfully created our custom character. Yes, my dear friends, we learned how to create our special character in this lesson. Let's continue with our next lesson. Yes my dear friends in this session we will learn about the module that necessary for us to perform our mimic movements. The module name we will use is media pipe. This module to with deep learning can detect the landmarks of our faces. We will also identify the landmarks in the lip area and learn our facial expressions when we smile or are said. So let's get started with the introduction lesson look. So as you can see here let's learn what is media pipe. Media pipe it's deep learning module developed by Google and also along with the media pipe facial landmarks may be found. As you can see here we have two different images here and here. The landmarks on the faces are here. Of course after finding the landmarks here we need to find the lip areas with the indexing method. So what do mean? We have representative image as you can see here also available in various number for example as you can see here 54 for example 333 and also for example 424. In fact each of these number represent landmark. We will learn our facial expressions through two indexes in the lip area. So here and also here. And in this way we will able to learn our facial expressions and print our facial expressions on our SED screen. Yes my dear friends in this lesson we learn about the media pipe module and about face landmarks. Let's move on to our next lesson and draw face landmarks. In this lesson, we will learn how to obtain images using the webcam on the computer. First of all, if we are going to use webcam, we should know about the following. When we want to show the webcam or video, we observe the images flowing in sequence. And when we want to open webcam with open CV, we have to do it in while loop because the webcam will read the sequenced images and output to us. So let's learn to use the webcam with the open CV module. Firstly, let's move to the project folder and let's create new Python file. and let the Python file name be for example webcam and also press enter. And now let's import our Open CV model. Let's write here import CV2. And now let's move to new line. If we are going to use webcam, we have to learn new class. The name of this class is video capture. So let's create new variable here. Let the variable name be for example webcam and also put equal sign and then let's call our new class CV2 dot video capture and also open parenthesis we need to enter the values zero or one in the parenthesis because this values is default since my webcam value is one and will enter one value and also however your webcam volume may be zero. Don't forget to try both. And now we have to create while loop. So let's write here while and also open parentheses. And let's write in the parentheses true and also put colon and move inside of the while loop. What we need to do now is to create two different variables because the first variable we will create will be the control variable. The other variable we will create will be the matrix that allows us to output image. So right here let the first variable name be control and put comma and let the second variable name be for example frame and also put equal sign and we have to read our webcam object. So let's write here webcam dot read. If we do like this, we have successfully read our frames. So let's move to the new line. What we need to do now is to output our frame variable with the im show function. So let's write here cv2. Show and also open parentheses and let the window name be for example result and put comma and let's write here frame. And finally what we have to do is create condition. So let's write here if and also open parentheses. This condition will allow us to finalize our code. Here we will set the weight function as response time. So let's write here CV2 dot weight key and also open parentheses and let's give the 10 value and also we will use the emp% sign. So put space and write on percent sign and also we have to put space and we will define letter on the keyboard with the ord function. So let's write 0x FF is equal to or RD function open parentheses and let's create quotes and let's write here for example and now put colon and let's write break. Why did we do like this? Because if we do not do this the system will give an error the operation we have done in the condition. If we press key for 10 milliseconds, our code will over. So now let's run our code. As you can see here, we have successfully get an output using our webcam. Now will show you my hand. And here this is my hand. All right, it looks perfect. All right, my friend. In this lesson, we learned how to obtain images using the webcam on the computer. So, let's continue with other next lesson. Yes, my dear friends, in this lesson, we will learn how to draw our facial landmarks using media pipe module. So, let's get started. First of all, let's move to the our project folder and let's right click and move to new and let's create new Python file here. For example, let the Python file name be media underscores test. And also let's press enter. And then let's import our media pipe module and also open CV module. So will write here import CV2 and also let's move to new line and let's import our media pipe module. import media pipe and also by the way will use media pipe module as MP. And if you do something like this we have successfully imported our modules. So now let's move to new line and let's create new variable here. So our variable will be webcam. So let's create webcam variable and put an equal sign and then let's call our video capture class cv2 dot video capture and also open and close parenthesis and let's assign it to value one. If your webcam value is zero, you should assign zero. And then let's continue. So now let's move to new line. Now we will learn to use the structures inside our media pipe module. The first of these will be the face mash comment. We will use our face function with this command. In this way we will be able to detect our facial landmarks. For this reason let's create new variable here. Let the variable name be for example MP underscores phase and also put an equal sign and let's write here MP dots solutions dot face mesh. If you do something like this we have successfully completed our first detection landmarks. So now let's continue and let's move to new line. In this new line we will create new different variable here. With this variable we will draw our facial landmarks. So let's write here MP underscores drawing and also put an equal sign and let's write here MP dosolutions dot drawing. All right we are done. What we need to do now is to use the face mesh function. First let's call the wid command. So let's write here width and then let's call our face mesh function. This is new function which we learn. So let's write here mpores face dot face mesh and also open and close parentheses. And also all of these structures we will use as for example face underscore mesh and also put colon and then let's move inside of our parentheses. We will enter two different parameters here. The first parameter will be our detection confidence and also the second parameter will be tracking confidence. So let's write here min underscores detection underscores confidence and put an equal sign and let's assign it to for example 0.5. If you do something like this it will detect with 50% or more accuracy. And also let's put comma and let's write here mean underscore tracking confidence. So will assign it to 0.52. And also let's move inside of our width indentation. And then let's call our while through loop because we will get the frames from the webcam. So will write here while true and also put colon and let's move inside of our while through indentation. So now we will create two different variable here. Our first parameter will be the control and also our second parameter will be the our frame. So let's write here frame and put an equal sign and let's read our webcam. So let's write webcam dot read and also open and close parentheses and let's move to new line. So we will check our control variable. If the control variable is equal to false so we will terminate our code. So let's write here if our control variable is equal to false. Let's break our code and also let's move to the while loop. All right my friend. Now we will convert our frame to RGB color format because in this way we can perform more precise detection process. So now let's create new variable here. For example, let the variable name be RGB and put an equal sign. And also let's call our CVT color function. And as you know our first parameter will be our frame matrix. So let's write here frame. And also our second parameter will be the CV2 colorbgr2 RGB. All right, we are done. So now let's move to new line. What we need to do now is to process our face mesh variable and assign our RGB frames with the process function. So let's create new variable here. For example, let's write result and put an equal sign and let's call our face mesh and put dot and let's call our process function. And also we will enter one parameter here. Our one parameter will be the our RGB frame. And as you remember our RGB matrix name is RGB. So will define RGB here. And also let's move to new line. So now let's create condition here. And let's write here result dot multi underscores face underscores landmarks and also put colon and move inside of our if condition. If you do something like this it means that the detection process is being performed. So now let's draw our facial landmarks. As you remember our landmarks is like index. So we should create for loop here. For example, let the element name be face underscore landmarks in result dot multi_ace landmarks and also put colon and let's move inside of our for loop. All right. So now we will draw landmarks of our facial landmarks. If you want to do this, we have to use MP drawing variable. So let's write here MP underscores drawing and also we will learn new function here. So put dot and let's call our new function. Our new function name is draw underscores landmarks and also open and close parentheses. Inside of parentheses, we will enter three different parameter here. So our first parameter will be the frame matrix. will write here frame. Our second parameter will be element name. So as you know our element name is face landmark. So let's write here face underscores landmarks and put comma and also as the last parameter we will enter the ready parameter to draw our facial landmarks. So our ready parameter is face mellation. If you want to use face mesh tellation, we will write here MP face dot face mesh underscores tessellation. All right, we are done. So now let's move inside of our while loop indentation and let's call our im show function. So let's write here cv2 im show and also open and close parentheses. Let the window name be for example test and also our matrix variable name be our frame matrix. So let's write here frame and then do not forget to use our weight function. So let's write here if CV2 dot weight key open and close parentheses and let's assign it the value 10 is equal to ESG button. Let's break our code. All right my friend we are done. So now let's run our code. And as you can see here, we have successfully reached our facial landmarks. Yes, my dear friends, in this lesson, we learned how to draw our face of the face. So, now let's move on to our next change. As you know when we run our code as you can see there are lines and circles covering my face. These lines and circles are very huge. Let's come now and change the properties of these lines and also circles. So let's get started. First of all, we need to change two parameters in the draw landmarks function so that we can change our physical properties. Our first parameter is landmark drawings patch. So let's write here put comma and let's write landmark underscores drawing underscore spec and also put an equal sign and then we will use new function here. With this function we can change physical properties of the landmark points. Our new function is drawing page. If you want to use this function, we have to use our MP drawing variable. Firstly, let's write here MP drawing and let's call our new function. Our new function name is drawing patch and also open and close parentheses. And then we can enter three different parameters here. our first parameter. For example, let's change the thickness value. So let's write here thickness. Put an equal sign and for example let the thickness value be value four and also put comma and our second parameter will be the our circle radius parameter. So let's write here circle radius and also put an equal sign. Let the circle radius variable be value three and also our last parameter will be our color. For example, let the circle color be blue color. Let's create tpple here. If you want to change circle color as blue, we should write here 255, 0, 0. If you do something like this, we have successfully changed our circle color. So now let's check our code. Let's run our code. All right, we have an error. yes, we didn't define our color parameter. So let's write here color and put an equal sign. All right, my friend, we are done. So now let's run our code. Yes, we get an error. Yes, found this. We wrote here the letter So we should write here landmarks, not lab marks. So let's run our code now. And as you can see here, we have successfully changed our color of the landmarks points. So let's continue. For example, let the decrease our thickness value. For example, let's write here value two. And let's change our circle radius. For example, let's write value two. And let the change color as red. So let's write here 255. So now let's run our code. And as you can see here, it looks perfect. Now let's continue. If you want to change our lines, we will define new parameter here. So our new parameter name is connection drawing patch. And also do not forget to use equal sign. And then let's call our drawing patch function. So let's write here MP drawing dot drawings patch and also open and close parentheses. For example, let's change the thickness value. So let's write here thickness and put an equal sign and for example let the thickness value be value one and put comma and let's change our color. So let's write here color and put an equal sign and let's create new tpple here and move inside of our tpple. For example let the lines color be green. So let's write here 0 comma 255 comma 0. And now let's run our code. And as you can see here we have successfully changed physical properties of our lines. So for example, let's continue move to the landmark drawings page and let's change our thickness value as volume one and let's change our circle radius value as volume one. And now let's run our code again. So here it looks perfect. All right, my friend. In this lesson, we learned how to change physical properties of our lines and also our landmark points. So, let's continue with our next lesson. Yes, my dear friends. In this lesson, we will install the necessary module for communication between Arduino and Python. So, why are we going to use this module? Because with deep learning, we need to transmit data that we are smiling or set to the Arduino board. For this reason, we need to take advantage of the serial module. Let's move on to the installation now. So, let's get started. First of all, let's open the partime IDE and then let's move to the terminal section and let's write here pip install pi serial and also let's press enter and as you can see here we have successfully installed pi serial 3.5 version. So let's check our serial module. Let's move to the project folder and let's right click and let's create new Python file here. For example, let's say test serial and let's press enter. And then let's import our serial module. So let's write here import serial. And let's move to new line and let's call our print function. And let's write here serial underscores version underscores. So now let's run our code. And as you can see here we have successfully installed our serial module and our serial model version is 3.5. Yes my dear friends in this lesson we learned how to install py serial module. So let's move on to our next lesson. Yes, my dear friends. In this lesson, we will write our Python codes for our project. So, let's get started without wasting any time. Before we started, let's move to the project folder and let's create new Python file here. Let the Python file name be for example final underscores project and also let's press enter. And as you remember we will import our modules. First let's come and include our open CV module. So will write here import CV2 and also let's move to new line and let's come and import our media pipe module. So let's write here import media pipe. Let's use this module as MP and then let's move to new line and of course let's not forget to import our serial module which is necessary for us to send signal to our Arduino board. So let's write here import serial and also let's move to new line. So now let's call video capture class for getting frames from our webcam. So let's create new variable here. Let the variable name be for example webcam and put an equal sign and let's call our CV2 dot video capture class and also open and close parentheses and will define the first parameter as volume one and now let's write our face mesh codes which are necessary for us to detect our facial landmarks. So let's create new variable here. Let the variable name be for example MP face and also put an equal sign and let's call our face mesh. So will write here MP dos solutions dot face mesh and let's call the command for drawing. So let's write here MP_drawing and put an equal sign and let's call drawing UTIS. So will write here MP dot solutions dot drawing underscores and also let's move to new line. In this new line we will learn new command. This new command is inside of our serial module. With this comment, we will be able to enter our port information and we will adjust our serial communication cate and the other name is rate CPI our new command and also our name class name is serial. So let's create new variable here. For example, let the variable name be Arduino and also put an equal sign and let's call our serial dot serial and also open and close parentheses. We will define two different parameter. Here our first parameter will be the our port number and also our second parameter will be the our serial communication speed. The port information is the USB line to which the Arduino board is connected. If you want to define port information, we should create single quotes and also we will write here com and then we will define our port number. So my port number is five. So will define as com 5 and also let's enter the second parameter. Our second parameter is rate speed. In general the rate speed is set to 9,600. For this reason, let's enter the value 9,600. Yes, my dear friend, we have created our necessary modules and variables in this lesson. So, now let's continue with our other lessons and realize our project step by step. Yes, my dear friends, in this lesson, let's continue from where we left off. As you know, we made the necessary definitions in our previous lesson. Now, let's call our face mesh function. So, let's get started. As you know, if you want to use facem function, we needed to call it using the width structure. So let's write here weight and also let's call our MP face variable and also put dot and let's call our face mesh and then as you remember we will define two different parameters here. Our first parameter will be the detection confidence. So let's write here main underscores detection underscores confidence and also put an equal sign and let's define this parameter as 0.5 and also put comma our second parameter will be the tracking confidence. So let's write it here main tracking underscores confidence and also let's define this parameter as 0.52 and also let's use this structure as face mesh mesh and also do not forget to use colon and let's move inside of our width structure. In this new line, we will call our while through loop because as you know we will get frames from the webcam. So let's write here while through and put colon and let's move inside of our while loop and then we will create two different parameters here for reading webcam. So let's write here control and also our second variable will be frame and then put an equal sign and let's read our webcam and then let's move to new line and let's call our if condition if control variable is equal to false let's break our code and also let's move to the inside of our while loop if you wanted to better display the landmarks on our face which you know we had to change our color format for this reason. Let's come and convert our image to RGB color format. So let's create new matrix here. For example, let the matrix name be RGB and put an equal sign. And if you want to convert our image, we should use CVT color function. So let's write here CV2 CVT color and open and close parenthesis. Our first parameter will be the source matrix. So our source matrix name is frame. So will write here frame. And our second parameter will be the CV2 colorbgr to RGB. And then let's move to new line. In this new line, we will process our face mesh variable. So let's create new variable here. For example, let's say result and put an equal sign. And let's write here face mesh dot process. And as you remember we have to define one parameter here. Our parameter will be the our RGB color format matrix. So let's write here RGB. And also let's move to new line. In this new line, we will come and reach the height, width and number of channels of our frame matrix because we need to think holistically while performing the detection process. So now we will create three different variable here. Our first parameter will be the height and put comma. Our second parameter will be the width and also our third parameter will be the channels and then put an equal sign and let's reach our height width and channels. If you want to reach these values we need to use new method here. Our new method is shape method. If you want to use shape method firstly we should write matrix name here. Our matrix name is frame and put dot and let's write here shape. If you do something like this, we have successfully reached our height, width and channels values. All right, my friend. So now let's move to new line. So now let's create new if condition. Here will write if and let's check our result multifphase landmarks. So let's write here result dot multi face landmarks and also put column and let's move inside of our if condition. In this condition we will create for loop here because we will find our facial landmarks. So let's write here for. So let's create new value here. Our volume name be for example face underscores landmarks and put this space and let's write here in result dot multioreface landmarks and also put colon and let's move inside of our for loop. All right my dear friend what we need to do now is to reach the special facial landmarks on our face. This lesson is up to here because in the next lesson want to talk to you about the theory of this. In this way when we learn the theory and continue our project will be more understandable. So let's move on to our next lesson. Yes, my dear friend. In this lesson, we will learn how to reach the landmarks on our face. In fact, the points on our facial landmarks are kept in certain indexes. Since we will do operation based on facial expressions in our project, let's take our lips as base. Each of our points in the lip area is specific. At the designated set indexes hold the coordinates of the points in the face region. We will be able to benefit from the indices located in the corners of the lip area. In this way we will able to reach our coordinates and learn our facial expressions. Look as you can see here have shown two different areas with the arrows. The indices of these two points are 306 and 61 respectively. We will reach the and information of these indexes. Yes, my dear friends, in this lesson we learned our indexes in the corners of the lips. Let's move on to our next lesson and let's draw our points. Yes, my dear friend. In this lesson, we will learn to reach our list define in face landmarks. As you know, coordinate information is kept in the list we will reach. So let's start now and draw the landmarks on the lip corners. As you remember our indexes of lift corners are 306 and also 61. So let's reach these points. Now for example, let's create new variable here. Let the variable name be for example one and let's put an equal sign and let's reach our landmark index. If you want to reach our landmark index we have to write here firstly face underscores landmarks dot let's write here landmark and also let's create square brackets and let's write index number. So as you know our index number is 306. If you do something like this we can get the and coordinates. So now let's reach and coordinate. If you want to reach and coordinates we should create and points. So let's write here basically x1 variable and put an equal sign and let's write here.1 dot And of course when we need to think holistically we should multiply this value by weight. So let's multiply by width. If you do something like this we can successfully reach the xcoordinate of the index number 306 in our lip corner. However when we want to draw our point we may encounter an error because the value x1 here can be decimal. Pixels are rendered as integer. For this reason, let's come the multiplication here and do the int conversions. So let's move to the beginning point of letter and let's write here int and open parentheses and let's move to the end and close the parenthesis. If you do something like this, we have successfully get the x1 value as integer. So now let's move to new line and let's create new variable here. Our variable name be y1 and let's get the value of y-coordinate. So let's put an equal sign and let's call our int function and let's write here point one doty multiply by height. All right my friends we are done. So now let's move to new line and let's draw our point. If you want to draw our point, we should use circle function. So let's write here CV2 dot circle and also open and close parenthesis. Our first parameter will be the our output matrix. As you remember, we will show our frame matrix. So let's write here frame and put comma. Our second parameter will be the our center. If you want to define center point, we should create tpple here. And then we will write here x1 comma y1. And also let's continue. So now let's put comma. And our third parameter will be the radius. For example, let the radius value be two. And let's put comma. And then we will define our color. For example, let the circle color be red. So let's create new tpple here. And let's write here 0 comma 0 comma 255. And then let's define the last parameter. Our last parameter will be the thickness. So let's define as three for example. All right my dear friends, we are done. So now let's come and check it. Let's move to the while true indentation and let's call our im show function. So let's write here cv2. and show open and close parentheses and let the window name be for example final and our second parameter will be the frame. So let's write here frame and also let's move to new line and do not forget to create if condition and also let's write here CV2 weight key and let define as value 10 is equal to ESG key. So if press the ESG key, our code will terminate. So let's write here break. All right. So now let's run our code. And as you can see here, we have successfully draw the point our lip corners. So here. All right, my friend. Let's continue. Now, let's create our other point. Now, let's move to the inside of our for loop and let's create new variable here. For example, let's write 2 and also put an equal sign and let's get the 61 index. So let's write here face underscores landmarks dot landmark create square brackets and let's write here 61 and now let's move to new line and let's create new x2 variable and also put an equal sign and let's call our int function and also let's write here point 2 dox multiply by width And then let's move to new line and let's create new variable. Here our new variable name is for example y2 and put an equal sign and let's call our int function and 2 doty multiply by height. All right we are done. So now let's call our circle function. Let's copy this and let's paste it here. And also let's change the points X2 and also Y2. And if you do something like this, we have successfully create our other point. So now let's run our code. And as you can see here, we are done. Yes, my dear friends, in this lesson we learned how to reach our list defined in face landmarks and also we learned to draw our points in the corners of the lips. So now let's move on to our next lesson and determine our facial expressions with mathematical calculates. Yes, my dear friends, in this lesson we will learn about the distance formula between two points. It's important that we learn this calculation well because we will learn our facial expressions with the distance between the two points we drove at the corners of the lips. So now let's get acquainted with our formula. Now as you can see we have square root operation. So here is the our operation and our horizontal axis is defined by points. So as you can see here is the x2 and also x1 point and also while our vertical axis is defined by points. So here y2 and also y1. If we subtract our x1 value from our x2 and subtract our y1 value from y2 value and if we take the second power of these values we subtracted so here and here and add them together we can reach the result we want. Yes, my dear friend. In this lesson, we learned about the formula that is necessary for us to realize our facial expressions. Let's continue with our next lesson and learn the distance between our lip corners. Yes, my dear friends. Now, let's come and use our formula with software. First of all, we need to use the math module to use our formula. So let's move to the top and let's import our math module. So will write here import math. And then let's move inside of our for loop and let's move to new line and let's create new variable here. For example, let the variable name be distance. And also let's put an equal sign. And now we will learn new function here. This function about the square root. If we are going to do the square root operation, we need to call the SQRT function in the math module. So let's write it here. math dotsqrt and then let's move inside of our parentheses sqrt parenthesis and of course we need to the exponential operations for this we need to use the pop function po function is inside of our math module so let's write here math dot po and also open and close parentheses and we will define two different parameters here Our first parameter will be the base. And as you remember our base number is x2 - x1. So let's write here x2 - x1 and put comma. And our second parameter will be the power. We will take the second power. So let's write here two. And also let's outside of our parentheses. And then let's put plus sign. And also call again pole function here math.pole and also open and close parentheses. And then let's write here y2 minus y1 and also put column and let's take the second power. All right my friend if we do something like this we can successfully calculate the distance between two points. Now let's move to new line and let's call our print function and open parentheses and let's print out variable distance. So will write here distance. And now let's run our code. As you can see we have reached numerical values. When smile my numerical value increases. When am sad my numerical value decreases. Yes my dear friend. In this lesson, we have reached the numerical values necessary for us to learn our facial expressions. Let's continue with our next lesson and send the signal to our Arduino board. Yes, my dear friend. In this lesson, we will send signal to our Arduino board. As you know, we calculated the distance between the lip corners in our previous lesson. These calculated values give us different results when we smile and different results when we are set. Let's come and now create our conditions according to these values. Before we started, let's run our code. As you can see when smile the values generally show 48 and above. For this reason let's create condition and if our distance so let's move to the for loop indentation and let's write it here. If our distance variable is greater than 48 let's send signal to our Arduino board. If you want to send signal to our Arduino board, we will learn new method. If you want to use this method, we have to use our Arduino variable. First of all, let's write here Arduino variable and put dot and our new method is write method. With this method, we will send signal to our Arduino board and also open and close parenthesis. And let's write here letter Why did we do something like this? Because we will send data as byte. The letter here represents the word byte and also let's move to the end and let's create single quotes and for example let's send signal like letter capital to our Arduino board. If you do something like this letter signal will be sent to our Arduino board. Now let's continue. Let's come now and send different signal this time when we are set. So let's move to new line and let's move inside of our for loop indentation and let's call our al if condition. And as you remember when we were set the distance value were for example 42 43 and also 44. So let's write here our distance variable is less than for example 46. Let's send different signal to our Arduino board. So let's write here Arduino dot write and also open and close parentheses and let's write here letter and let's create single quotes. For example, let's send data as for example letter If you do something like this, when we smile, letter signal will be sent to our Arduino board when we are set the letter Yes, my dear friend, this is how our Python codes are in general. Now, let's write our Arduino codes and test our project. Yes, my dear friend. In this lesson, we will write our Arduino codes. First, let's come and include our LCD display library. So let's move to the top and let's include our liquid crystal underscores I2C.h and also let's move to new line and let's define our acid screen. First let's create acid screen variable. So will write here liquid crystal I2C and also let's give name to our I2C as screen class for example let's say CD and also open and close parenthesis and let's put semicolon and let's move inside of our parentheses as you remember our first parameter will be the our acid secret address so my acid The secret address is 0 27 and let's define number of columns. So our number of columns is 16 and put comma and let's define number of rows. So as you remember our number of rows is value two. And then let's move to new line and let's create new variable. Here we will create variable of type chart. With this variable, we will read the data that comes from Python. So let's write here char and put space and let's give name. For example, let's write here incoming data and also put semicolon and then let's move inside of our setup function and let's start the sedd. So let's write here sedd.bin. begin and also open and close parenthesis and put semicolon and let's move to new line and also let's start the serial port. If you want to start serial port we should write here serial the letter should be capital. So let's write here serial dobe and open and close parenthesis and put semicolon and let's move inside of our parenthesis. We will define the rate Citate. As you remember our rate speed is 9,600 and also let's move to new line and let's call the set cursor function. So will write here sedd dot set cursor and open and close parentheses. And let's move inside of our parentheses. We will define the beginning point. So our beginning point is 0 comma 0. All right my friends we are done. So now let's move to the loop function. Now what we have to do is create condition here. With this condition we will learn whether the signal is coming to our Arduino board. So let's write here if and also open and close parenthesis. And let's create curly brackets. And let's close the curly brackets. And then let's move inside of our parentheses. And let's write here serial dot available is greater than zero. Our logic here will be as follows. If data comes to our Arduino board, the condition here will be true. And also let's move inside of our curly brackets and let's read the data. We will assign the incoming data to the variable named incoming data. So let's write here incoming data and put an equal sign and let's read our data. If you want to read our data, we should learn new function. Our new function name is serial dot read and also open and close parentheses and put semicolon. When we do something like this, we can learn the data coming to our Arduino board. So now we will create new condition here. With this condition, we will check the data. For example, if the letter signal comes, we will print smiling with our asset screen. If letter signal comes, we will print set. That's why we create new condition here. So let's write here if open and close parentheses and let's create curly brackets here and then let's move inside of our parentheses and let's write here incoming data is equal to letter Firstly let's call the set cursor function. So will write here sd do set cursor open and close parentheses and put semicolon. Why did we do something like this? Because in this way we can continuously print text at the starting point. So let's move inside of our set cursor function and let's define the starting point 0, 0. And let's move to new line and let's call our std.print print function and open and close parentheses. Put semicolon and let's move inside of our parentheses. Let's create double quotes and let's write here smiling. And then let's move outside of our if condition and let's call our as if condition. With this condition, we will check the letter So let's create parentheses and let's write here incoming data is equal to letter Let's create curly brackets here and let's call set cursor function. Open and close parenthesis. Put semicolon and let's move inside of our parenthesis. We will enter the parameter as 0 comma 0. Here is the beginning point. And also let's move to new line. And let's call the print function. LCD.print open and close parentheses and put semicolon. And let's move inside of our parentheses. Create double quotes. And let's write here set. All right, my friends. We are done. So now let's verify our code. So let's try it here. Final project and let's save this file. Yes, we have an error because we have forgotten available parenthesis. So let's create open and close parenthesis. If you do something like this, we can successfully verify our code. So now let's verify again. All right, my friend. As you can see here, the compiling is done. So now, let's upload our code. And as you can see here, we have successfully uploaded our code. Now let's move to our next video and check the project we made. Yes, my dear friends, we will now test our project. Let's come and run our Python codes. Now will share the asset screen with you. As you can see, we were able to send signal to our Arduino board successfully and we can get outputs according to our facial expressions. However, the text you see here are writen on our SD screen. In particular, wanted to show you the error that occurred here. So, how can we fix this error? Actually, fixing this error is very simple. report this it will be enough to make small addition to our Arduino code. What we need to do is to clean or as secret before the set cursor function in our conditions. In this way we can achieve the desired result. So now let's open the Arduino IDE and let's move to the if condition here and let's write here std.clear and also open and close parenthesis and put semicolon. And then let's move to the as if condition and let's write here std do.clear again and also open and close parentheses and put semicolon. And now let's verify our code and also let's upload our code to the Arduino board. All right my friends we are done. So now let's open the Python codes. So now let's run our code again. As you can see, we have reached the desired result. Yes, my dear friend, there is no limit to what we can do in the software world. If there is question or problem that you do not understand in the videos up to this point, please do not hesitate to ask. This is sero motor you see in my hand. Servo is defined as drive system that performs angular linear position, speed and acceleration controlling mechanism without error. In other words, it's motion control mechanism. Ser motor are the most used motor type in robot technologies. In our other project, we will use sero motor because we will do joint movement with the sero motor. All right. We generally have three different lines in our servo motor. You see the brown line is the ground line. So here is our ground line and also the red is the five voltage line. So here this is the middle line and also the orange is our signal line. Together with Arduino we can control our sero motor angularly. So now let's make our connection first and get our codes ready for use with Arduino. So let's get started. All right. So here is our Arduino and also we need some cable for connections between Arduino and server motor and let's do this operation now. So first let's start with our brown cable and as you remember the brown line is representing our ground line. So let's wiring to the ground. So you see here let's focus this now. All right. So let's select the ground and also the middle which color is red. We should connect to the five voltage pin. So here is the our five voltage and also the last one is representing our signal. So we should use PWM port. So let's do this now. will choose the night port. And by the way, you can also use different PWM ports in the Arduino. So let's select night port now. All right, my dear friends, we are done. So now let's connect our Arduino to the our computer. All right, we are done. Yes, my dear friends, in this lesson we learned what is sero motor and also how to connect server motor to the Arduino. So now let's move on to our next lesson and let's learn how to control sero motor using Arduino. Yes my dear friends, in this lesson we will provide sero motor control with you. in order to do this operation. First of all, let's open the Arduino IDE. So will open my Arduino IDE now. So let's click this and also it's opening. And you see here and also let's create new source code now. And here is our new source code. And also then we need to add new library to our source code for sero motor control. The name of this library is server.h. So let's include this. Now as you know if you want to add any library to our Arduino code what we have to do now is to include our library. So for this operation first let's use an hashtag here and let's write include and also let's use less and larger sign and let's move inside of our less and larger sign and let's include our servo library and we are done and also if you want to control our server motor what we have to do now is to create new object which is our servo object. So for this we need to learn new object here. The name of this object is servo and put space and then we need to give name to our object. For example, let the object name be servo and also put semicolon. All right, we are done. So now let's define our pin number of our server signal port. As you know this is nine port and also for this operation let's move inside of our setup function and also let's delete this command and then we need to call our object variable name here. So this is sero as you know and also we need to learn new function here with this function we will define our pin number. So the name of this function is attach and also open and close parentheses and put semicolon. And now we need to define our pin number. As you remember our pin number is nine and that's why entered the nine value as first parameter. All right, we are done. So now let's verify our code and also let the file name be for example sero control. And let's save this file. And you see here the compiling is done. So now let's control our server motor. For this operation, we need to learn new function in our server object. The name of this function is write function. So if you want to use write function, let's move inside of our loop function and let's call our servo object again and put dot and let's call our right function and open and close parentheses and put semicolon. Now we need to determine the angle of our servo inside of our parenthesis. If we enter the value 90 here, the angle of our servo will be 90°. So now let's check our code for this. First let's verify and you see here the compiling is done and also will show you my server motor right now. All right. So now will upload my code to the Arduino and you see here is the our 90° of our sero motor. And for example, let's change our degree of server motor. For example, let's change as 45 here. And if we run our code again. And you see here, this is our 45 angle of sero motor. And for example, let's change is 180. And if you run our code again and you see here is the result and also this is our 180° of our servo motor. So here is the result. And by the way want to give you some information about our sero motor. Our servo motor can rotate between 0° and 180°. That's why we need to define between 0° and also 180°. All right, my dear friends. In this lesson, we learned how to control server motor using Arduino Uno board. So, now let's move on to our next lesson and let's build our second project. Yes, my dear friend. In this lesson, we will start to create our mechanism so that we can realize our project. As you know, we will make project that we can move our arms as representative in our project. With this project, we will perform our elbow movements according to the distance between the shoulder and the wrist. So, what do mean? Look here, we have piece from shoulder to elbow. We also have piece that goes from our elbow to our wrist. We use image processing and computer vision when the distance between our wrist and shoulder is close. Here we will use server motor also. We will come and accordingly bring our wrist closer to our shoulder. So just like that. Of course not limited to this. If it moves away, we will control our servo motor in the opposite direction. Actually, that is basis of our project. As you can see here, we have two different papers here. Actually, we divide our arm into two different parts. The first paper is representing from shoulder to elbow and also its distance is 25 cm and also the second one is represent or from elbow to wrist. And by the way, second part is 27 cm. In other words, we can actually think of it as normal person's arm. Yes, in this lesson we learned about our project together with you and learned the dimensions of our arm parts. Let's continue with our next lesson and create our arm. Look, we have arm pieces that we have drawn here. Let's come and cut these parts and make them suitable for sticking on our cardboard. come and take my scissors and start cutting. Look this part of our arm represent from elbow to wrist. So we are done. So now let's come and cut our second part of arm. And of course you can find all of the papers on source section of this video. And you can free to download and print this project sources. All right my dear friend we have successfully handled cutting operation of arm. In this lesson we cut our arm parts. So now let's move on to our next lesson and stick the pieces we cut on the cardboard. All right my dear friends. So now let's continue. prepared my parts of arm and cardboard. Now what we need to do is to stick our paper on the cardboard. After glouing we will cut and paint our piece of arm cardboard. So now let's do this operation. All right, my dear friends. As you can see, we have done the pasting process. Now, let's come and cut it. Yes, we made our first cut. Now, let's go and do this for the other cardboard. Yes, cut it quickly here for you because wanted to show you quickly. Now that we have cut our cardboard, we can paint our paper. will use the cream color for this. Of course, you can also choose your own color. So now let's do painting operation. So will take my color. And by the way, will also use crayons. Yes, my dear friend, we have successfully painted our first part of our arm. So now let's do this operation for the second one. Yes my dear friends as you can see we have successfully handled our painting operation and for example look at the our arm now if the wrist moves closer to our shoulder we will control like this and otherwise if it moves away we will control like this. So this is the basis of our project. Yes my dear friend in this lesson we created our arm. So now let's continue with our other lessons and create our other mechanisms. Yes my dear friends we have rectangular cardboard as you see so that we can fix the arm we will make with this cardboard we can easily fix our arm of course another issue is that our cardboard looks beautiful for this we will use two pieces of blue colored paper look here will come and fix my arm and also will place the shoulder and elbow part of my arm here. And then my sero motor will be fixed in the position you see. As you already know, we will use the sero motor as an elbow. Then the other part will be fixed on our sero motor. In this way, we will be able to perform the opening and closing operations of our arm. So now let's come and set up our background. Let's apply glue to the back of the papers you see here. Then we paste it on our cardboard. All right. So now let's paste our blue paper to the cardboard. So now let's do the same operation for second paper. So now let's paste our blue paper to the cardboard again. All right, we have done our pasting process. Now will share the size of the cardboard with you. Our cardboard is 48 cm wide and also 32 cm height. All right. Now that we know the sizes of our cardboard, so now let's cut the excess parts. All right, my dear friends, we have completed the cutting process. Now all we have to do is stick our fixed piece to our cardboard. Let's do this operation now. Yes, my dear friend, we came and glued our fixed piece to our cardboard. This lesson is up to here. With this lesson, we have come to the end of our setup. Let's continue with our other lessons and let's do the other operation for our setup. Yes, my dear friends, in this lesson we will continue from where we left off. In this lesson, we will fix our sero motor to our elbow. Look, as you can see here, we calculate the midpoint of our elbow. What we need to do is fix our servo with the help of hot silicone. So, let's do this operation. Now, as you can see, the midpoint of our elbow is defined by the blue line. Also, would like to inform you about this issue. It's important that we position our sero motor because we will control our sero motor between 180 and 90°. For this reason, we must position like this. As you can see here, so let's continue. First of all, let's squeeze our hot silicone to the middle point. Then let's keep our sero motor on it. Now what we have to do now is to keep our serum motor on the hot silicone. Let's hold on little. When we control the motor, you see here it looks perfect. So let's continue now and you see here we have successfully pasted our serome motor to the elbow of our arm. So now let's do glue operation between our cerometer and also our second part of arm. So let's do this operation. Now you see here this is the middle point of our second part of our arm and also it must be on our server motor parts. So that's why we should pay attention too and also with this operation we can successfully do glo operation for our arm project. Finally, let's come and fix our other part to our sero motor. And by the way, we need to hold it longer while doing this process. Yes, my dear friends, as you can see, we have successfully completed our setup. So now let's continue with our other lessons and write the necessary Ardino and image processing thoughts. Yes, my dear friends. In this lesson, we will write the Python codes of our project together with you. So, let's get started. Let's move to our project folder and let's create new Python file here and let the Python file name be pos detection and also let's press enter. Let's go ahead and import our required modules. Let's import our OpenCV module for our image processing codes. So will import our OpenCV module and of course let's import our media pipe module to detect the landmarks of our arm. For this let's import our media pipe and also let's use our media pipe as MP. And as you know we need to import the seral module in order to send signal to our Arduino board. So for this let's import serial module. Finally let's import our math module here. With this module we will calculate distance between wrist and shoulder. So will import my mat model here. So we are done. So now let's open our webcam. For this operation we need to call video capture class. So now let's create new variable here. We can also say object. For example, let the object name be webcam and put an equal sign. And let's call our CV2 video capture class. And as you know we can enter two different parameters here. These are zero and one. And also my webcam ID is one. So that's why entered volume one here. If your camera ID is zero, you should enter the zero in the parenthesis. So let's continue. Now let's come and change the properties of our camera. In this way, we will be able to make more accurate detection process. So for this, first we should call our webcam object and also we should call new method in webcam object. So which name is set method. With this method, we can successfully change width and height of our webcam. And also, if you want to use set method, we should enter two different parameters here. The first parameter will be our properties ID. For example, if enter value three here, we can successfully change the wid of our webcam. If you want to change wid of webcam, let's put comma and let's enter the width size here. For example, let the size be 1,280. And also let's move to new line. So now let's change height of webcam. So let's call here webcams set again. And now we should enter the value for here. With this value, we can successfully change the height of webcam. So for example, let the height of webcam value be 720. And also if we run our code like this and you see here we didn't get any error. So let's continue. Now let's come and define our variable required for arm detection. For this operation we should use our media pipe module. So let's move to new line and let's create new variable. Here we will assign new Python file to our variable. For example, let the variable name be MP pause and also put an equal sign. And also if you want to detect arm detection, we should call here MP.ol dot post and we are done. And finally, we need to define our port in order to send signal to our Arduino board. For this let's create new variable here. Let the variable name be for example my Arduino and put an equal sign. And for this operation let's call our serial module and also let's call our serial class open and close parenthesis. In the parenthesis we will enter two different parameters here. The first parameter will be our port and also the port volume must be string variable type. So let's create double quotes here and let's define port number which relationship with Arduino. So my port value is com 3 and also your port number can be different and put comma and finally we should enter our rate speed as default the value is 9,600. If we do something like this, we can successfully open our port and also we can successfully send signal to our Arduino board. All right. Yes, my dear friend. This is how we define it in general. So now let's continue with our next lesson and write our other necessary codes. Yes, my dear friend. In this lesson, we will write the necessary codes to create our ARM model together with you. As you know, the variable we created here is actually the Python file. Now, what we need to do is to open this Python file and define our required class. As you know if you want to do this operation first we should call here with structure and also we will call here our Python file variable name. So as you know this is MP pose and also put dot and if you want to detect any arm using media module we should call here post class and also open and close parenthesis. In the parenthesis we will enter three different parameters here. The first parameter will be our static image mode. So what is static image mode? Actually if you want to assign value true, it allows us to detect with the webcam. So that's why we should assign as value true. So let's call here static underscore image mode and also let's define as value true and also put comma. So now the second parameter will be our detection confidence. As you know we will define as 0.5 because 50% accuracy is enough. So that's why we will define as 0.5 here and also it represent 50%. And finally the last parameter is our min tracking confidence. It will be the same as the our min detection confidence. So let's call here mean tracking confidence and let's define 0.5 and also not limited to this we will use all of these class as for example post and also put column and let's move inside of our width structure. All right we are done. So now we should create loop here because we will get the frames from webcam. So this is realtime application that's why we need to call here while true loop and let's move inside of our loop. All right my dear friend we are done. So now we need to read our webcam for this operation. As you know we should create two different variables here. The first variable will be our control variable and the second parameter will be our frame and also with this variable we will get the frames from webcam. So for this reason let the variable name be frame and put an equal sign and let's call here webcam dot read method. So we are done. So now let's move to new line. Now we need to change our color format. As you know the default color format is BGR in open CV module. Actually media pipe module supports RGB color format that's why we have to change that. So for this let's create new matrix variable here. Let the matrix variable name be for example RGB and also if you want to change any color format using open CV module we should call here CV color function. So let's call CV2 dot CV2 color and also open and close parenthesis. In the parenthesis we will enter two different parameters here. The first parameter will be our input matrix that we want to change color format. So as you know this is our frame matrix. The second parameter will be our color format values. If you want to reach all of these color formats. So let's call here C2 dot color underscore and as you know our color format is BGR and also we want to use as RGB so that's why we should write here BGR to RGB so we are done so now let's continue all right my dear friends since we have changed the color format of our image let's come and reach our webcam sizes for this as you know we use the shape method The reason we do this is because we have to think holistically the coordinates we have obtained because the model we will create returns values between zero and one. That's why we should reach our webcam sizes. So for this we should create three different variables here. The first variable represent our height and the second variable represent our width of webcam and also the third one is representing our channel number. So we should use as underscore here and also let's put an equal sign and let's call here. As you know if you want to use shape method using open CV first we should call here our matrix variable name. So as you know this is frame and also put dot and let's call here shape and we are done. Now what we need to do is to process our model. As you know if you want to do this operation we should use process model in our model. So for this let's move to new line and let's create new variable here. Let the variable name be for example result and put an equal sign and also if you want to process our model what we have to do now is to call here our pause variable. So let's write here pause and also put dot and let's call here our process method and also open and close parenthesis. In the parenthesis we will enter one parameter here. The parameter represents RGB color matrix. So as you know this is our RGB and if you do something like this we can successfully process our model. All right my dear friends we are done. In this lesson we learned the necessary steps to detect our model. Now let's move on to our next lesson and detect our arm and its regions. Yes, my dear friends, we will continue from where we left off in this lesson. In this lesson, we will perform wrist, elbow, and shoulder detection with you. As you know, we need to know the index number required to perform this operation. Look, there are indexes that we can use here. The ones we will use are the 16th. So here 16th, 14th and also 12 indexes. In this way we can detect our arm representatively. So let's do this operation. Now for this let's open our PC time IDE again. In this time we will create an if condition here because with this condition we will check whether there is arm contact or not. So for this let's create if condition here and also if you want to detect arm what we have to do now is to reach pause landmarks in results for this operation. Let's call our result variable here and also put dot and let's check our pause landmarks and also put colon and let's move inside of our if condition. So now we need to get the landmarks of our special points. As you know these are wrist, elbow and also shoulder. For this let's create new variable here. Let the variable name be for example wrist and also this variable represents our wrist coordinate and also put an equal sign. And by the way if you want to reach the wrist coordinate of our arm what we have to do now is to reach the landmark of our post landmarks. For this let's call here our result variable again and let's reach our pose landmarks and not limit to do this. If you want to reach the landmark, we need to call here dot landmark. And also this list represent coordinate of our wrist. And also let's create square brackets. And by the way, if you want to reach the wrist coordinate as you know we need to reach the our index number of our wrist. So this is 16. And we are done. And also let's move to new line and let's get the coordinate of our wrist. For this let's create and variable because these are representing our wrist coordinate. For example, let the variable name be x1 and put an equal sign. And of course we have to convert to integer conversion function because as you know pixels are made up of integers. So that's why we need to call here integer type convergent function and also open and close parentheses and let's reach our xcoordinate of wrist. For this let's call here our wrist variable. And if you want to reach the xcoordinate so let's write here dox and also not limited to this. We need to multiply this value with our video of our webcam because we need to think holistically. So let's multiply by our width and we are done. So now let's move to new line and let's do this operation for our y-coordinate. So let's create new variable here. Let the variable name be y1 and put an equal sign and let's do integer tip conversion again and let's reach this time where is doy and multiply by this time as you know this will be our height value of our webcam. So we are done. So now let's draw circle using these coordinates. For this as you know we should call here our circle function and also open and close parenthesis and in the parentheses we will enter five different parameters here. The first parameter will be our output matrix that we want to show our circle. As you know this is frame and also the second parameter will be our center point. We have already calculated our center point of wrist. These are x1 and y1. And also the third parameter will be our radius. So let the radius value be for example 20. The fourth parameter will be our color. For example, let the color be red. So for this let's define 0 comma 0 and comma 255. And we are done. So now let's enter our last parameter and the last parameter will be our thickness. If set as minus one here, we will get the field circle. So this is great. That's why enter it minus one here. So let's continue. So now let's do this operation for our elbow of our arm. So let's create here new variable. Let the variable name be elbow and put an equal sign. And let's call this time result dot close landmarks and also put dot again. And let's reach our landmark list and open and close cur brackets. And let's enter the index number of elbow. So as you know this is 14. So let's enter here 14. All right we are done. So now let's get the and coordinate of elbow. So for this let's create new variable. Let the variable name this time x2 and let's call our integer type conversion function and let's reach elbowx and let's multiply this time our width. All right. So let's do this operation for our y2 variable. So let's create y2 and let's call here integer type conversion function and let's reach this time elbow. and let's multiply this time with our height. And also let's draw circle for our elbow. For this, let's copy our circle function here. And let's paste it here. And just let's change the coordinates as X2 and Y2. All right, we are done. Finally, let's do this operation for our shoulder. Let's move to new line again and let's create shoulder variable and let's reach this time our shoulder variable and ycoordinate. So for this let's call result dotpose landmarks dot landmark and also open and close square bracket and as you know the index number of our shoulder is 12. So let's define as 12th. All right, we are done. So now let's reach the and ycoordinate of shoulder. So let's create x3 variable and let's call here integer type conversion function and let's call our shoulder.xcoordinate and let's multiply with our width variable. And finally let's create our y3 variable. And let's call integer type conversion function again. And let's reach our y-coordinate of shoulder. And let's multiply this time with our height variable. All right. And also let's copy our circle function again. And let's paste it here. And let's change just coordinates of circle as x3 and y3. All right. My dear friend, we are done. In this lesson, we detected and drove the necessary arm regions together with you. So now, let's continue with our next lesson and examine the output of the model we created. Yes, my dear friends, in this lesson, we will test the code we wrote. First of all, let's come and view our frame matrix so that we can do this for this operation. Let's move outside of our if condition. And as you know, if you want to show any matrix using open CV module, what we have to do now is to use im show function. So let's use im show function. Now for this, let's call here CV2. im show and also open and close parenthesis. In the parenthesis we will enter two different parameters. The first parameter will be our window name and let the window name be for example arm detection and also the second parameter will be our matrix variable name that we want to show on the screen. As you know this is our frame matrix. So let's display now our frame matrix and also not limited to this. We should create new condition here because we will get frames from webcam. So as you know this the default settings that we want to display our webcam on the screen. So for this let's create an if condition here and if if press 10 millisecond forgk let's break our code. As you know if you want to do this operation let's use our weight key function here. So if press 10 millisecond the ESG key. So why did enter here 27? Because our ESG key ask value is equal to 27. That's why entered 27 here. And also put colon and let's move inside of our if condition and let's break our code. All right, my dear friend, we are done. So now if we run our code, all right, we got an error now. So yes, this is about our serial communication because we didn't connect our Arduino to USB port of our computer. Let's comment our my Arduino variable. And if we run our code again. All right. You see here we got the output like this. And also if show my arm to the webcam. So let's look at this now. And you see here it looks perfect. So here is the result. And by the way we can display our arm. Beautiful. So for this operation for example we can draw line between our wrist point and also our elbow point and the other hand we can draw line again between our elbow and also our shoulder. So let's do this operation now. So now let's break our code. will break my code now. For this operation, let's move inside of our result.puzzle landmarks condition again and also move to the bottom of our condition. And as you know, if you want to draw line using open CV module, we should use our line function in open CV module. So for this, let's call here CV2 dot line function and open and close parenthesis. And as you know, we will enter five different parameters here. The first parameter will be our frame matrix that we want to display on the screen. So as you know this is frame and also the second parameter will be our first point. As you know let's think about our arm. This is our wrist. This is our elbow. And let's think about this is our shoulder. If you want to draw line between two points, for example, this one and this one, we should use this one coordinates and also this one coordinates. For example, if it is x1 and y1 coordinate, the ending point will be our x2 and y2 coordinate. If you want to draw line between this point and this point and if this line coordinate is equal to x1 and y1 and also if you think about this is our starting point this will be our x2 and y2 coordinate. So it's very simple. Let's do this operation. Now as you know if you want to draw line between our wrist and elbow these coordinates are x1 y1 and x2 y2 orderly. So for this let's create new tpple here and let's define our starting point as x1 and y1 and also the third parameter will be our ending point. As you know the ending point is equal to our elbows coordinate. So these are x2 y2 and also the third parameter will be our color. For example, let's draw blue line for this operation. Let's create new toppel and let's define as 255 comma 0 comma 0. And also the last parameter will be our thickness. For example, let the thickness value be value two. And also let's copy our code again. And let's move to new line and let's paste it here. And let's draw line between this time elbow and shoulder. As you know this time our starting point is starting from x2 y2 and also our ending point is equal to x3 y3. All right my dear friends we are done. So now if we run our code and also will show my arm to the webcam and you see here it looks perfect. So here is the result. So now let's continue. Yes my dear friend in this lesson we have seen the arm detection. So now let's move on to our next lesson and complete our necessary mathematical calculations. Yes my dear friend in this lesson we will calculate the distance between the shoulder and the wrist. For this we will use the distance formula between two points. As you know we use similar logic in our previous project. So now let's do this operation. As you know if you want to do this operation we need to get coordinates of our wrist and also our shoulder because we will control our ser motor using this operation. So let's continue. Let's move to new line and let's create new variable here. Let the variable name be for example distance and also put an equal sign. And if you want to calculate the distance between two points, what we have to do now is to do square root operation. So as you know if you want to do this operation, we should use our math module. So let's call here math module. If you want to do square root operation, let's call our SQRT function and also open and close parenthesis. Now we have to subtract and square for the and coordinates. So what do mean? Let's do this operation now. First let's do exponential operation. For this as you know we should use PO function in our math module. So let's call here M.PO and also open and close parentheses. If you want to get power of any number. First we should write here which value that we want to get power of. As you know let's start with our coordinate. Our shoulder coordinate is equal to x3. Right? We should subtract x3 with x1 because we will calculate between our wrist coordinate and also shoulder coordinate and also not limited to this. We will take the second power of this value. So let's put comma and let's take the second power and also we are done. So now let's move outside of our parentheses and let's addition our y-coordinates and also we will do exponential operation again. So let's call here math.po and open and close parentheses. And then let's do this operation for our y-coordinates. As you know these are y3 minus y1. And also let's take the second power of this value again. So let's write here value two. All right my dear friend we are done. So now for example let's print the distance value. If we run our code like this. So will run my code. And you see here we are getting the distance between our wrist and shoulder value. If close my arm and you see here the distance value is decreasing and the otherwise the value is increasing. So here is the result. It's decreasing and also it's increasing. So we are done. So now let's continue. Yes my dear friends in this lesson we have calculate the distance necessary for us to control the server motor. Now let's continue with our other lessons and sending signal to our Arduino board according to the volume we have obtained. Yes, my dear friends, as you know, we've performed the necessary calculation process in our previous lesson. Now, we will send signal to Ardino board according to the value we have obtained. When we open and close our arm, we get value between 0 and 600. In general, value between 0 and 250 represent closing our arm. The value between 250 and 450 allows us to close our arm halfway and also 450 and above represents open arms. We will send signal to our Arduino board according to these values. So let's get started. For this operation, let's move to the top and let's create function. Let the function name be for example send signal to Arduino and also we will take parameter here. The parameter will be our distance value and also let's move inside of our function. All right. So now we should create conditions here. This condition will control the server motor connected to our Arduino board. So let's create if condition here. And what did say? If our distance value between 0 and 250, our arm is closing. Right? So let's check this now. If our distance value between zero and 250, let's move inside of our if condition and send the signal to our Arduino board. And by the way, let's delete this command. And also, let's call here my Arduino variable. And as you know if you want to send signal to our Arduino board what we have to do now is to call here our write method. So let's write here write and also Arduino takes any data as byte type. So that's why we should write here letter here. And also let's create single quotes. And for example let's send signal which is letter If we do something like this, our arm will closing using sero and also let's continue let's do this operation closing our arm halfway. So as you know for this let's create new if condition here and if our distance value between 250 and 450 let's move inside of this condition. So let's check 250 is less than our distance value and also is less than or 450 value. Let's move inside of our if condition now. And this time for example let's send signal as letter and we are done. And finally, if our distance value is greater than 450, let's move inside of this condition. So let's check if the distance value is greater than 450. Let's move inside of our condition and let's send signal this time. For example, letter So let's call here my Arduino.right Right? And let's send as by type. And let's create single quotes. And let's send letter here. All right. My dear friends, we are done. Finally, we need to call our function. So for this operation, let's move inside of our if condition and let's move to the bottom and let's move to new line and let's call our function. As you know our function name is send signal. All right we write wrong here. Let's change as signal underscore to our duino and let's define our first parameter as our distant variable. All right my dear friends we are done. In general our Python codes are like this. So what we need to do now is to write and test our Arduino code. So now let's move on to our next lesson and complete our code by creating our Arduino codes. Yes my dear friends in this lesson we will write the Arduino codes of our project. As you know, we have completed our Python codes. And by the way, we want to use our server motor. For this, we need to include the server library. So, let's do this operation. Now, let's move to the top and let's include our sero age library. And also, let's move to new line. Now, we need to assign the incoming data to variable. For this we need to create variable of type chart. So let's move to new line and let's create new variable as an chart data type and for example let the variable name be incoming data and also put semicolon and then we need to create server object for defining pin and also controlling our server motor. So let's move to new line and as you know if you want to create server object let's write here sero and for example let the server variable name be servo and also put semicolon. So now let's come and define our servo pin. As you know if you want to do this operation we need to move inside of our setup function. So let's delete this comment first. And also if you want to do this operation first let's call here our object as you know this is servo and here we will use our attach method because with this method we will define our servo pin as you know our sero pin number is nine so that's why entered here value 9 in the parentheses and also put semicolon and of course let's start the serial communication since we will communicate over the serial port. So for this let's move to new line and let's call here serialbe and as you know we need to enter one parameter here which is our bud rate speed and when we complete the our Python code we defined our serial port rate speed as 9,600. So let's define as 9,600 here and put semicolon. And finally let's move to new line. And now let's come and set the starting angle of our sero motor. As you know, we need to set it in full open our arm. Therefore, we need to set it to 180°. And also, if you want to control our sero motor, let's call here first our servo object and put dot and let's call our right method. And also open and close parentheses and put semicolon. And let's move inside of our parenthesis. And let's define as angle 180. And if you compile like this our code for example let the file name be arm movements. And also let's save this file. And you see here the compiling is done. So now let's continue with our loop function. Now what we need to do is to control the signals coming to our Arduino board. As you know we will control our server motor according to the this controls. For this process first we need to check whether signal is coming to our Arduino board. As you know if you want to do this operation let's move inside of our loop function and let's create if condition here and let's check if any signal is coming to our Arduino board. So if you want to check this operation, let's call here serial dot available and also open and close parentheses and let's move inside of our if condition here. And then we need to check which data is coming to our Arduino board. As you know we created here incoming data variable and also we need to read which data is coming to our Arduino board and also we will assign our incoming data to our incoming data variable. So for this let's call here our incoming data variable and put an equal sign and also if you want to learn which data is coming to our Arduino board. So let's call here serial dot read function and also put semicolon. All right my dear friend we are done. So now if you verify our code and you see here we didn't get any error. As you know our arm will have three different movements. It will perform these movements according to the incoming and signals. For example, if the signal is coming, we will define our sero motor to 45° that is it will be completely closed. So let's do this operation now. If our incoming data is equal to letter and also letter will be capital. Let's control our server model is 45. So for this let's call here servo dot write and let's define as 45 and put semicolon as if our incoming data is equal to big letter Let's control server motor degree as 90 because this is half closed. And finally our incoming data is equal to big capital letter let's control our ser motor degree as 180 and also it's representing our arm is opened so that's why we define as 180 All right my dear friends, we are done. Our Arduino codes are generally like this. Let's load our code now. First, let's verify our code. And you see here we didn't get any error. And if we upload our code to the Arduino board and you see here we have successfully uploaded our code. All right. So now let's open our Python codes. And here is our Python codes. And let's run our code now. Yes, my dear friends. As you can see, when we test our project, we encounter the result exactly as we want. When my arm is open, it's fully open. When closed, it's fully closed. And when it is half open, it's half open. All right, my dear friend. This lesson is up to here. So now let's continue.