I mean it has its own ecosystem. It has its own ide. You have to install that ide and write the code there and upload the code from there. Only so where did this python come from? This is what im exploring in this playlist first phase will be on how to take the components, the sensors and trigger them, or control them with python commands and in the second phase, well create some actual projects. Well, use these sensors well use our knowledge that we have already acquired in the first phase to create some real life projects. Like lets say, we have 10 to 15 plants and we put moisture sensors on each plant and collect the data and then apply some machine learning algorithms to create a perfect model for the moisture of a specific plant. Okay. This is just an idea: well create similar projects in the phase two of this playlist, okay and uh. If you want to stay updated with all the videos of the playlist, you can do two things. First, you can turn on the notification for this channel. I dont beg for subscribers. This is not my thing. If you want, you can turn on the notification bell or what you can do is ill provide a link of my newsletter in the description you can go to that google forms and enter your email id there and well use that email id and some question asked There to send you all the relevant video links and relevant blogs.

So if you want, you can do that. Okay! So, moving on to this video, first of all, we have to install one package uh, so open cmd and write pip, install pi, formatter, okay, pi formatter uh not fit mata its a formatter press enter and uh. I guess we have used pi formatter for our ultrasonic sensor, video and yeah. This is not the first video of this playlist. We have already created two videos. We have explored two sensors first was the esp32 wifi, cam and second was ultrasonic sensor. Okay, so we have used pipharmata, i guess for the ultrasonic sensor, okay, so uh! The package is installed here now. What you need to do is you need to go to the arduino ide? Yes, you have to install arduino ide ill, provide the link of this id in the description you have to install this id. Let me maximize it, then what you need to do is you need to go to tools, tools, manage libraries. It will take some time to open uh. They need to write formatter here for mata and uh. This is the package that you have to install. This is the library that you have to install this is built by fermata team only, and this is the version that im using so just to be sure, select this version from this drop down menu. Okay, so uh after installing this, a small button of install will be present here. Just like this one just install the package, uh click close now with the packages being installed lets get to our editor so that we can start writing our code.

This video is sponsored by codetribe. Let me inform you about a amazing resource for learning dsa and to become a part of a budding community of programmers and motivated student who are working together to learn and become better programmer on daily basis. This is the youtube channel. Go tribe you will find one of the best programming educators in the country who have came together to give you all top class learning content about data structure and algorithm. Now on this channel get live and interactive classes, record lecture series and some fun session too. At no cost whatsoever – and all this is available on youtube itself, so you can watch as per your comfort also. They have created a brand new series on the dynamic programming which will help you get well versed with dynamic programming in just two hours. So what are you waiting for, subscribe to code tribe and become part of a revolution to programming education from the ground? Up? All the links will be provided in the description, so definitely check them out. Okay, so we are not in a editor before we uh write the python code. What we need to do is uh. We need to go to this files uh this examples, uh go to this formatter and uh standard formatter. Okay, select this standard formatter file then connect your arduino with your laptop okay. So i guess i have to show you the connection first. So lets go to the connection.

Okay, so lets see the connection of our arduino uno and servo motor real quick. So these are the two components that are required for this project. First is the microcontroller, which is a arduino uno. I provide the buy link for both of these products in the description, if you want to buy the specific model that i im using and uh, this is a server motor and to be specific. This is this is sg90 okay. It took me some time to focus. Okay, so the connection is pretty simple: there are three main wires to this: uh brown, red and yellow. Let me focus to this okay, so, as you can see, we have brown red and yellow wires. The brown wire will be connected to ground, so this brown wire is this black. So lets connect this black to the ground. Connect this to the ground, the red one or the middle one is the vcc, so it will be connected to 5 volt 5. Volt is just adds uh adjacent to ground. Okay. So let me turn this now. You can see five fold. Okay, so i have placed ground wrong. I guess these two pins are for ground and just adjacent to ground. We have five volt and then the last pin uh the yellow one or uh. The orange one will be connected to the digital pin. So uh we are connecting to digital pin 10.. You can connect to any digital pin, you want.

These are the digital pins and we are connecting it to 10th, okay, but you can connect to any digital pin you want now. If you want this to be systematic, you can connect this on a breadboard but uh. It is not a requirement. Okay, uh then connect this power cord to our arduino like this and then connect this usb port to your laptop okay. So this was the connection part now lets get to our editor so that we can start writing a code okay. So now we are back from the connection, so uh lets upload this code to our arduino okay. So it will take some time. Okay, so the code is uploaded, as you can see, done, uploading dont be intimidated by this red color. This is not the red color of error. Okay, now, after this code is uploaded on the arduino uno, you can now close this id and lets see our code. Okay, the code is pretty simple. All the task is done by the package only so this is the code uh, so uh. We have to install arduino servo and utils from our of bipharmata. As i have already told you, this pyfarmata can be used for multiple sensors okay, so we have already seen ultrasonic sensor. I guess it controls the dc motor also ill just check that, and i guess it controls uh potentiometer. So these are the sensors coming up in this playlist uh. Then we have time we are importing this package to add some delay.

Then we are specifying the port okay. So i need to open arduino id again so that i can show you how you can check what the port number is. Port number is actually the usb port on which you have inserted your arduino, so uh just go to tools, and here you can see this is the port okay. So whatever is written here, port two port, five porter, fifty whatever it is, you have to write that port here, okay and then this is the pin whatever pin connection. I have shown you now. I have connected it to 10, the digital 10 pin. Now you can connect from 1 to 13 to any pins. You can connect it wont matter. Then we are creating the arduino board instance. So uh this board variable is the arduino class instance, and this is the port variable. Having a port, then board dot. Digital pin, pin is 10 10 dot mode is equal to servo. So we are saying that okay, uh on this arduino uno board at the digital pin 10, the mode connected or the component connected, is servo. Okay, this is a servo motor. Then we are creating an infinite loop here. You can have one input, two input. Whatever you want im creating a infinite loop. Then we ask the input from the user. The angle at which the user wants to rotate the servo motor and if the x is one, the servo motor, will rotate the blades of the servo motor.

Actually its plastic, but uh lets say its blade. Uh. The blade will rotate from 0 to 180 degree. So foreign, then 0 to 180 and uh well call this function here. Okay, so just understand that this for loop is going from 0 to 180 0 is the resting point of the blade and 180 is 180 degree? Okay, then we are calling this rotate servo function. So this is the rotate servo function. It has two parameter. First is uh the pin the pin at which the servo motor is connected, and then i this i variable: okay, 0, 1, 2, 3 to 180, so uh board dot digital pin dot right. Okay, so we are writing on this servo motor. What angle this i angle, okay, this is i – and this is angle hem, so i angle and i is increasing from 0 to 180, so the blade of the servo motor will also move from 0 to 180 and after each 1 degree, move well have a 0.015. Second delay: okay, then this was uh for 180 degrees. Well, do the same for 90 and for 270, okay, so uh. If the user inputs 1, it will go for 180 degrees. If the user inputs 2, it will go for 90 degrees and if the user inputs three, the servo motor blades, will go to 70 degrees, okay, so yeah. This was the code part. Let me connect arduino uno and my smartphone to the tripod and show you the output, okay, so lets run our code and uh.

Actually, my sublime text is having some problems, so i have to upload the code from terminal okay, so i have uploaded the code. As you can see, the led is blinking and our servo motor is running the now. Let me press the first button or the first key and, as you can see, our rotor of the servo motor is rotating. Let me uh pick it up and show you okay. So let me zoom in a little bit and uh. Let me upload two here: okay, okay, let me upload three here and uh focus: okay yep! This is it. This was a short video in which i have shown you that how you can control servo motor with arduino and python. Now, if you want me to create a specific video on a specific sensor, then do comment down below and let me know what sensor you want and uh.

https://www.youtube.com/watch?v=tJaXkdNaCQw