Arduino Robotics With Scratch Programming Skills in TinkerCAD With Projects | Bazeer Ahamed Mohamed Nishad | Skillshare
Search

Playback Speed


1.0x


  • 0.5x
  • 0.75x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 1.75x
  • 2x

Arduino Robotics With Scratch Programming Skills in TinkerCAD With Projects

teacher avatar Bazeer Ahamed Mohamed Nishad, Design Engineer and Founder - Robototec

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

    • 1.

      Introduction to The Course -Course Overview and Projects

      4:15

    • 2.

      Sensors

      8:10

    • 3.

      Actuators

      2:19

    • 4.

      Controllers - Arduino Explained

      12:50

    • 5.

      Exercises

      20:58

    • 6.

      Flowcharts

      12:41

    • 7.

      Project No 01 Home Security System

      32:17

    • 8.

      Project No 2 - Object Detection System

      28:59

    • 9.

      Project No 03 - Smart Dustbin System

      35:22

    • 10.

      Project No 04 - Obstacle Avoiding Robot using L298N Motor Controller

      57:02

    • 11.

      Project 05 - Line Following Robot

      50:13

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.

93

Students

--

Project

About This Class

Arduino Robotics With Scratch Programming Skills in TinkerCAD With Projects

This is the original comprehensive course for Arduino makers and inventors by using scratch programming in TinkerCAD. Students can learn to design circuits, code and build robots by learning this exciting course. The explanations are given for each step you have to follow from the beginning if you are new to Arduino. This course provides you the overall understanding about the working principles of Arduino and scratch programming. You don’t have to copy others' code anymore. You can code yourself for your innovative projects. Arduino needs C++ Program natively to upload codes. But here, the TinkerCAD software will generate the C++ Programming from the scratch program that we write. But how to write a scratch program? Don’t worry. Here, I have explained to you an easy way to create a scratch program by using flowcharts. Therefore, you can create programs for your own projects.


Method of Study:

Here, I will explain 5 different projects to you. If you learn those 5 you are not limited to work on only 5 projects. You can create tons of different projects by learning the working principles of the electronics components, circuit design and scratch coding. First, you have to focus on the projects. And follow my steps. Then you have to achieve the simplified version of the projects. After you have achieved the simplified version of them, then you can expand it. Such as you can add more sensors, change the code, combine our projects and increase the complexity of the projects. That is how I advise my students to practice my courses. Then you can understand the theories and practicals clearly. Throughout the study, if you don't understand anything you can ask me questions. I am always available for my students to clarify their doubts.

Who can learn this course?

  • Age above 10 years

  • Absolute beginners to Arduino

  • Intermediate students to Arduino

  • Parents who wish to teach Electronics, Robotics to their kids

  • STEM educators & Teachers

  • Hobbyists with no programming background

What are the benefits?

  • Free Software Access to practice Arduino Robotics.

  • Free Simulation is available for checking our program and playing around with different changes in the circuit.

  • Everyone can learn visual programming easily.

  • No need to copy others' code. We can create our own code.

  • Even for simplifying the Scratch Program Flowchart method was used.

  • Wiring diagrams with Engineering Best Practices are explained clearly for professional circuit designs. Starting from early childhood.

  • Free Download and Installation guides for Arduino IDE Software are provided.

  • Project Based Learning - 5 Interesting projects will be explained clearly.

  • No C++ Coding. No Problem. We will program in Scratch Visual Programming Language. Then the software will automatically generate the C++ code for us.

What is included in this Arduino Robotics Course?

  • Free download of Lecture Notes with Wiring Diagrams, Scratch Programs and C++ coding for the projects.

  • Free software is sufficient to practice Arduino Robotics. But, if you want to practice practically, you can buy some electronic components. The links to buy suitable electronic components from Amazon are provided for reducing the surfing time for electronic kits.

  • Safety First. Safety guidelines are explained clearly before start working on electronics.

Projects in Arduino Robotics With Scratch Programming in TinkerCAD

  1. Home Security System

  2. Object Detection System

  3. Automatic Smart Dustbin System

  4. Obstacle Avoiding Robot

  5. Line Following Robot

Why Scratch Programming in TinkerCAD for Arduino Robotics?

Scratch is the world's largest coding community for children and a coding language with a simple visual interface that allows young people to create digital stories, games, and animations. Scratch is designed, developed, and moderated by the Scratch Foundation, a nonprofit organization.

Best of all, TinkerCAD Circuits provides a bottomless supply of virtual components that students can use to build and simulate their projects. When they're ready to physically prototype their projects, TinkerCAD Circuits makes it easy to export their code as a native Arduino.

Meet Your Teacher

Teacher Profile Image

Bazeer Ahamed Mohamed Nishad

Design Engineer and Founder - Robototec

Teacher
Level: All Levels

Class Ratings

Expectations Met?
    Exceeded!
  • 0%
  • Yes
  • 0%
  • Somewhat
  • 0%
  • Not really
  • 0%

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.

Transcripts

1. Introduction to The Course -Course Overview and Projects: Hello, students. Welcome to a new course in robotics. Here in this course, we are going to learn about ordinal robotics, without any codings. Because if I talk about codings, the students might afraid about that one. So I'm going to reduce that one. We are going to learn dino robotics without any coding. So how can we control the robots? Yeah. In this course, I'm going to explain to you how we can do the scratch programming. Easy programming that we can do by drag and drop future. In this way, everyone can learn robotics very easily and efficiently. So let's talk about what we will discuss in our course. So basically, this is the course overview. We will learn about the introduction to the basic robotics. What are the things we will learn in robotics, maybe electronics, electrical things, what are the components that we use, and especially, I will introduce you a software in order to practice what we have to practice. So basically, that particular soft daa can be accessible by your smartphone or your computer or whatever the device you may have, right? Basically, it's just a website, and we are going to create an account, and then after we can use that particular Softaa for our simulation purposes. So in that particular software, we will have some electronic components, and we can do the programming. And also the important benefit from that particular software is we can generate the code from scratch programming to cplus pest coding. We can automatically generate the code for us to write it on the dinar. How cool is that? So we are going to learn that Softaa, I will explain it to you step by step how you can access to the softia. And then we will learn about what are the electronic components that may require for us to design the robotics components and the projects. So basically, in this course, we will discuss five projects. And first of all, we will make a home security system. And the next project will be object deduction system. As an example, if any person near sensa and then that particular sensa will detect that person and it will alarm or maybe it will indicate through an able. And the third project that we will look after is automatic small dspin system. On that particular project, we will make a project that if we wanted to put our garbages to the dapins and then we have to near to the dapin and then it will automatically open up the lid, and then after we put our garbages or the dusts, then it will be closed automatically. So that project will be discussed in our course. And then we will learn how to make some moving robots as an example, obstacle avoiding robot. How we can make a robot that can avoid obstacles, if there is an obstacle present in front of the sensa and then it will turn, right? And the final project that we will discuss in this course is line following robot. So we design a predefined path on the floor. And our robot will follow that particular path according to our design. It can start, turn and stop. So these are the projects that we are going to discuss in this course. So this one will be very interesting for us to learn. So let's just look after how we can interact to the software. 2. Sensors: So here, we have several types of sensors we may use in robotics. I will talk about only six projects in this basic robotic course, but if I teach you only six projects, that doesn't mean you can only do those six projects. That doesn't mean, right? So if I talk about six projects, you can expand it. Why? Because all the sensa that have three pins may work similarly. If I teach you how we can connect a three pin sensa then you can explore how to connect other sensa Maybe as an example, if I use flame sensor how we can connect. And then you can connect other sensa how we can connect the pad sensor and how we can connect the temperature sensa, raindrop sensor et cetera, right? So we have to be aware about that one, so we can do a lot of projects, if I teach you only six projects, right? Okay. Basically, we have first one is Pats search sensor. It's like a R sensor. It will emit infrared rays, and then it will be reflected back to this black color sensight the blue color is a transmeuor and the black color one is a receiver. The signal will be reflected back to here, and this is the sensor, but entire thing is a sensor module. Why? Why we call them as modules? Because the module can be used by the user over a person by having these three pins, right? Basically, we will have three pins. I will tell you what are those pins, right? So basically, we will have a pin. CCP, we may have ground pin GND pin or the third pin that we may have called as out pin in this particular sensors. So what those meanings are? You can think about VCC is simple. We have to give power to that particular sensor As an example, if you wanted to operate your TV, via remote, what will you do? We have to power up the remote control. Then after we can press the button to change the channels on the TV, right? Likewise, the sensors are also working similar. We have to power In order to get the job done from the sensor, we have to power them up. If we do so, then only we can connect them to other circuits or maybe with the controllers, right? So first pin may be VCC. That is the power pin. We have to obtain the batteries positive terminal and then connect it to VCC. If we see GND or the ground pin of the sensa what we have to do is we have to obtain the negative terminal of the better and connect it to that particular sensa module. Then after we have connected those two pins, C and the ground with the bed, then you can notice that in the module, a bulb will be turned on. That means the sensa has been powered up correctly. And then after we will be left only one pin. Right? So that particular pin is called as out pin, right? So that particular may be signal pin, right? So sensors may have written as signal pins, right? So that particular pin is a signal, right? Whenever Sensa detects something, there will be an output voltage, right? So as an example, if we use one path search sensor if there is any object present in front of the sensa and then it will provide five voltages. If the sensa doesn't have any object in front of that particular sensa range, and then output signal will be zero. It will provide us zero voltages instead of five voltages. So what that means is if the sensa is working and then it will provide us five voltage. If it is not working and then it will provide zero voltage on the signal pin, or maybe out pin. That is how the sensors are working. And I have just explained to you how they are working, right? But same three pin sensors are working like this, right? But particularly the ultrasonic sensor is a little bit different. I will explain it to you how we can connect the ultrasonic sensor later. But this sens flame sense laser head sensor clock module, soil sensor, drop sensor, they are working same, right? Right. So the difference is between the sensor is sensing property, right? So the flame sensor will detect if there is any flame, it will provide as five voltage, if there is nothing, and then it will provide zero voltage on the output, right? So that is the conclusion of that one, and laser head sensor the laser beam is reflected from this particular sensor if the laser beam is cut down anywhere else, and then it will provide as the voltage difference, right? So basically, in here, We have two types of sensors. One is digital type sensors, and another one is analog type sensors. So digital sensors are only providing either zero voltage or five voltage. But analog sensors are different from digital sensor. Analog sensors can provide zero voltage or five voltage in between voltages as well. So that is the difference between digital sensor and analog sensa there are tons and tons of sensors available in the market. We can find out the different kinds of sensors according to our requirement. We have soil sensor. It can detect soil moisture capacity, whether we have the moisture content in the soil or not, raindrop sensa if the rain comes and then it will produce electricity. Likewise, you can think about different projects from each sensa by using each sensa how many projects we can do. There are tons of possibilities. You can think about it. And we have a lot more sens, ultrasonic sensor, human body sensa PR sensa tilt sensa, photosensitive sensor, sound sensor, et ce. There are tons and tons of sensors available. I'm not going to go through one by one because each the basic idea is same, but the difference is sensing property. Tilt sensor can sense the tilt angle, how much is the tilt tangle of the sensor currently is. Right? And ultrasonic sensor is different. It has four terminals, four pins on the pins category, and I will tell you how we can connect ultrasonic sensor in the project later. 3. Actuators: Now, we are going to learn about actuators. Actuators are different from sensors. Sensor will sense something. Some physical properties will be sensed by the sensor. But the actuators are different. They will do the job. Whatever the job we want, they can do according to their specific conditions. As an example for the actuator is motor. Motor will rotate and LE balds alarms, buzzers, and display. Those are actuators. Or in other terms, we can call them as output devices. They will produce the outputs. Okay. So here are some examples for the actuators, you can see that and here are some examples of motors, they are tons and tons of motors available in the market, according to our requirement, we can choose the right motor, and you can notice that the motors are different, right? So basically, these motors are called as DC motors, and these motors are servomotors. So if I talk about the servomotors, instead of DC motors, what the servomotors will do is They will keep an object at a position that we desire, right? So if you take DC motor, it will continuously rotate. But the servo motor, it will take a position and it will place on it, right? So maybe some servomotors are limited to zero to 180 degrees. Only in between those degrees, the motor can position the objects. Okay. And these are some linear actuators. So this is a linear actuator motor, and they are some geared motors as well, geared DC motors. Okay. 4. Controllers - Arduino Explained: Talk about types of ordinal. So there are some different kinds of dinos available here. So before we talk about the types. So basically what is arduino, Arduino is a device or a controller that controls the inputs and outputs together. Maybe, let's say, if you see that a ball is coming to hit you. So what will you do if you see the ball. And then you will suddenly recognize that the ball is approaching to you, and then you will try to catch it. Right? So like this simple phenomena, you can think about in terms of electronics, right? As an example, if there is any object present in front of the sensa the sensa will sense that particular object and it will sense the electrical signal or the electrical voltage to the dino or the controller. And then the controller will detect, the sensor detects something. And then it will actuate the motor or the LD bulb or whatever the output we wanted to connect it, right? So that is what happens in electronics. So the sensors will obtain the signals, right? Recognize them, and then the controllers will control, this is the output, this is the motor that should rotate according to this particular sensors input, right? So that is what will happen by this arduino. It will control. So I'm talking about controlling, right? So how can they control? Is they automatic? Yeah, they are automatic, but we have to program it. So how can we program it? It's very simple on these kinds of ordinos we can connect them to our computer or our smartphones. By using the computer or the smartphone, there is a specific software called as Arduino IDE. And on that particular Softa we can do the coding. But the codings are on C language, right? So maybe C language may be hard for some students, but I will just introduce you the visual programming method. In the Tinkercad Softa we will do the visual programming, and then it will automatically convert it to the C language. And then that particular C language will be uploaded by the Softa on your computer or your smartphone, and then the Adina will be programmed. So that is the process, right? After the ardino is programmed, now we can connect the circuits. Maybe the sensas and actuators, batteries, and other electronic stuffs can be connected to the Arduino, and then it will work according to our program. So now I'm going to explain about Arduino, right? So basically, if you obtain an Arduino, right? So in the dino, you will have some different kinds of ports or the pins, right? So basically, this particular pin, This particular pin is a primary power pin, a battery, maybe a nine voltage battery or five voltage, the battery can be connected to this particular barrel. This barrel can be connected by this particular battery. We can connect it. That's the first way of powering up the Arduino. The second way of powering up the dino is you can obtain a laptop or your computer, and then you can connect it via the USB cable. So you can use the USB cable to connect to this ordino. But you have to keep in mind that the dino should be only powered up by only one source at a time. So we can't power up the battery and we can't connect this particular wire together. Because if you do that, so then the voltage high voltage will be damaged the ordino, right? So you have to keep in mind that. If you are connecting the battery, you have to remove this cable. And if you are connecting this cable, you have to remove the battery. So that is the process, right? And on the dino, we have another additional one port to power up the dino, that is called a pin, right? So the battery positive terminal should be connected to this particular in pin, and the negative terminal should be connected to this particular ground pin. Then after the dino will be powered up. As well, right? So in this particular do, we have three powering up ways. In Odinomega you will have these three as well, but in the dino nano, you will have two ways. On the first way is USB cable and the second way is this one. You're not going to have this one. On the dino nano. Okay. So that is how you power up the arduino, right? So the rdino can withstand at 23.3 voltage two, 12 voltage, right? So the optimum voltage will be five voltage or nine voltage can be supplied to the arduino, right? And The important thing is why we use battery, right? I told you earlier, we have to power up this device. If you wanted to get the job done from this device, you have to power it up, right? So if you wanted to power up, you have to supply the current to this deal. That is why we are connecting this with the battery and you have to be aware about the connections, right? If you are going to program the rdino you have to use this particular terminal to connect it to your laptop via the USB cable, and then you have to remove this battery, and that is how it works, right? So after maybe if the dino is attached with a robot, what you have to do you have to move your laptop as well when the robot is moving, right? So that is not a best practice. For that, we have to remove this USB cable. After the programming is done, we will remove this USB cable. And then after you will connect a battery with this barrel or you will supply the power via this one, and then it will work, right? So this particular terminal is for programming purpose, right? Not for primary power supply, right? And Okay, so these are the power terminals that we have. So in this power terminal, this is in. That means voltage input to the ordinal. And then we have two and other pins, like five voltage pin and three voltage pin. That means 3.3 voltage pin, right? So these pins are different. Right? So let's say if you are using this particular motion sensor, and then you'll have these three pins. VCC, GND and signal. These three pins are there on the motion sensor or whatever, right? So what we have to do is we have to power up this sensor also. So this sensor should also be powered up. So for that, we can connect this sensor from this battery. Oh, what we can do is we can obtain the power from this particular dino and connect it to this VCC. That means we are obtaining the power from this dino. So then we can connect this five voltage from this VCC, and then we can obtain the ground from this Rd and connect it to this ground. And then the signal pin, right? So this is the important pin, right? So this signal pin can be connected to one of the analog pins or one of these digital pins according to the sensor capability, right? So if the sensor is analog, you should connect it to this analog terminals. If the sensor is digital, you can connect it to this one. Right? So here, you have digital pins, like zero, one, two, three, four, up to 13. And then you will have another ground terminal as well. I'm not going to explain these things AF and these things because these are advanced things. I'm not going to cover them in the basic robotics course, right? And then you'll have some electronics, ICs, transistors, et cetera, right? So those are not necessary in this course. But here, these two terminals are important, Tx and Rx pins. These are called as communication pins. Why we use these pins. Right? So basically, the pins are for bluetooth communication, right? So if you are using a Bluetooth module, if you are going to control anything from your smartphone, you should use this pins. That is all about the pins here in here. You can have the analog pins and power pins and digital pins, right? So this is the flow that comes, right? So basically, you have to obtain a battery, and then you will have a laptop. You have the Arduino, and you have the Senza This is Sensa This is your laptop. This is a battery. Basically, you have to connect the battery to this arduino. Then from the battery, the ardino will be powered up, right? So from the arduino, you can obtain this five voltage and connect it to the sensor, and then you have to obtain the ground and connect it to this one. Then the sensor will be powered up. And then you have to connect this pin like this. The signal pin can be connected somewhere else. Right? So that is how the workflow, right? So you have to connect the battery and the ardino and the dino will supply the voltage necessary for this particular sensor to power. But the problem is we can't obtain much voltage from the ardino as an output voltage because these are small voltage, five voltage, of course, but the current is very small, right? So if you are using several sensors, maybe five sensors or six sensors or mot, you can't obtain the power from the ardino. So what you have to do is you have to supply the power from an external source, or maybe you can obtain from the battery and connect it to this one, right? So that is how you do this one. So hope you understand about this one. So if you are going to program this dino, you have to disconnect this one and connect it to your laptop, and then you can upload the program after the program is successfully uploaded, and then you can remove this cable and then you can connect the Battery again. So this is the process of using the ordeno. 5. Exercises: And let's do an exercise to get an understanding about what we have learned so far. So draw the schematic diagram for the following figure. So this is the figure that maybe we can obtain this particular actual circuit. What you have to do is you have to draw the schematic diagram for this one. It's very important. Whatever the project we do, we have to convert it as a schematic diagram. Why? Because if you wanted to transfer the project or you wanted to explain the project to the others, you should convert this to as a schematic diagram. But what I draw in schematic diagram is slightly different. It may be a standard one. I prefer to use the color coding and standard symbols, et cetera. Right? So can you do this example. So basically, if you understand this one, it is connected to the battery, and then you can notice that the positive terminal, they used a red color cable to this breadboard. And then they obtained another cable to connect it here. And then they have connected the LE, and then the LED bulbs negative terminal is connected with the resistor, and then the resistor is grounded. So maybe it's a basic thing, right? The resistor is connected after the LED bulb. Right? So it's not a problem, whatever, right? If you put the resistor in front of the AD valve or after the LD valve. It's not a problem. It works as C. Why? Because the current on the circuit will be drawn at which the current is required for, right? So it's not a problem. So as an example, if I draw this diagram, you can notice that. This is the battery, and then this is connected to the resistor. And then it is connected to the LED al. So this is the standard symbol for the LD al. And then the LED alb is grounded, right? It's not a problem if you place the LED alb over here and the resistor there. It's not a problem, right? Okay. But this is wrong. Why? Because the color coding is not defined in this particular diagram. What I wanted to do is I wanted to make the diagram like this. Why? Because here in this simple diagram, you can notice that, right? So the red color is for the positive and the blue color is for the negative. And you can notice that, right? So the ground is connected by this blue color line and the red color line is positive. Right? So that is how we brow aschematic diagram. Okay. Exercise number two, how will you connect this circuit diagram by using a bread board. So What we have done so far is simple. We designed the circuit actual circuit, and then we gathered the schematic diagram. But now we are reversing the process, right? So here we have a schematic diagram, and we have to make an actual circuit. You can notice that how the system has been arranged together, right? So the nine voltage battery is connected. And then With the battery, there is a switch, W one, and then we have a resistor, and then the resistor is connected to the LED alve then finally, the LED bulb is grounded, right? So here, so these are the required components that we may need. LED al a breadboard, resistor, battery, and a switch. Basically, this is push button. You can use this push button because this push button is readily available in the electronic shop, and why I use this particular push button is because we can attach this push button on our bread bowl. All right. So here, we are going to do this particular exercise on our Tinkerct software, right? So we are going to practice this one. So after we practice these things and then we can get to know about software and how we can do the system works. Right? So I wanted to head over to the Softahre then I wanted to go this one, TinkercT then I wanted to head over to the circuit and then click Create New circuit. So this is the circuit in Tinkerctsft. What I'm going to do is I'm going to rename this project. As exercise number two, and then it will be renamed as it is. And then I'm going to drag and rob some components in order to get the job done. So basically, in this particular diagram, you can notice that we have to have nine voltage battery, a push button, resistor, and an LED b. So I'm going to quickly insert them. So if I type battery, it's the nine voltage battery. I'm going to drag and rob that one. So it's very simple. You can click and dragon drop like this. And after the dragon drop, you can press R on your computer to rotate this component. Or maybe you can click this one to rotate. And after that one, I'm going to insert a push button. So this is the push button, and I wanted to insert an LED bob. So this is the LED Bob and the resistor. We. If you don't want to search the components, what you can do is you can go to this one and click all components, and then you can find out the components from this as well. Okay. Okay. Now, additionally, so if you are going to connect this particular circuit in real life, you may have to connect or join wires together. So how can you join the wires? So you will obtain two wires manually and then join them together. That's wrong. That's not the best practice. So instead of that, what we have to do is we have to insert a breadboard. I'm just going to insert this particular breadboard minbreadboad. Okay. This breadboard has been inserted here. And now I wanted to align them all in this particular breadboard, right? I'm going to talk about some best practices by connecting the breadboard, right? So you can't connect this push button here and the resistor there and the LD bulb. It's totally wrong. Why? You have utilized the entire space on this breadboard. That is wrong. What we have to do is we have to use a small portion of the breadboard, right? We have to use the minimum space that we can use, right? So you have to utilize to minimize the space when we are using this particular bread board. And then the second thing you have to consider is you have to connect all the components, right? So the push button, resistor, LDs, maybe sensors, actuators, all the components together. After the connection is done, then after you have to connect this particular battery to the breadboard to power. So the powering up will be done finally. After all the components have been connected to the bread bowl, right? So that is the second tip. And then the third tip is you have to use the color codings, right? So you have to use different kinds of wires to connect them, right? So then only maybe another student or the client or the person who is in need of this particular design, they may understand your design what you have done so far on your design, right? So you have to use the color codings. That is the third tip. And then the final thing you have to consider is you have to name them, right? So maybe if you are using different kinds of components, you can name them, right? So this is push button. You can name it as push button one or resistor. You can change the values of this particular resistor. In our case, we may need 330 resistor. I'm going to change this unit to and type 330, and then I can name it as resistor one. And then I can rename the LED, maybe LED one, and then you can change the color if you want, maybe orange or yellow. I'm going to go with this red color. Right. Okay, let's connect them together, right? So this is how you connect, right? So you have to obtain this particular push pattern and then connect it like this, right? In the center, you can connect like this. So then for the push pattern here, we have four terminals. You can notice that if you move your mo cursor near to this terminal, you can notice that. This is terminal one B, this is one A, This is two B, and this is two A, right? So we have four terminals. And then you can notice that the four terminals are connected to each of the line on the breadboard like this, right? So if you connect like this, this is wrong, right? Because this line and this line are intersecting together. That means this is a single wire, so we cannot connect them properly. So make sure that you connect like this and For the resistors, if you connect the resistor in this manner, that is also wrong. Why? Because you have short circuited this particular resistor. That's wrong. What we have to do is we have to rotate this particular resistor and connect it like this, right? So if you connect like this, what happened? So this line, this particular wire is connected with this particular resistor, and then on the other terminal of the resistor, we can connect another cable. Right? So as I told you earlier, we have to reduce the number of parts in using this particular circuit design. So how can you tackle that particular problem? So what you can do is instead of placing the resistor here, right? If you place this particular resistor, what you have to do is you have to obtain a cable and connect it like this, right? And then you can change the colors and all the things. But here, you are using another part. Right? So this wire is an additional part. In this particular circuit, we don't necessarily need this particular wire. So I'm going to delete this particular wire by clicking this one or click the delete key on my keyboard, so then it will be get rid of that one. Right. Now, what I'm going to do is I'm going to drag this particular resistor and connect it on this particular edge. So what will happen? Now you can notice that, right? So this wire is connected with this resistor already, right? So we have removed that additional wire. So that is how we reduce the number of parts in using the circuit design. I'm going to do the work, right? Let's start working this particular one. So nine voltage battery is connected to this particular switch here, and then I'm going to drag and drop the switch, and then on this positive terminal, the switch is connected like this, right? And then what I'm going to do is I'm going to connect a resistor like this, right? And then the resistor will come over here, right? So you have to connect like this x mark, right? One B and two A should be connected together if you wanted to press this button and work, right? So for that, I'm going to connect this particular resistor in here, right? So then the line is going through here, and then it will pass through this one. Right? And then finally, I wanted to connect this resistor with the LED al. So I'm going to have this particular LD valve. In this LED valve, you can notice that. This is the positive y, right? So like curved one is the positive and this is the negative, right? So I'm going to connect the positive. So maybe I can rotate this one like this, and then connect it like this. Then the resistor is connected with the positive terminal, and then I'm going to connect the negative terminal on the battery here, right? Now, I wanted to change the wire to hook up because I will use jumper cables to connect them all. So I need to use these hook up cables you can notice that the block mark appears like this. And then this line is positive. Right? So I'm going to color it as red color. And this line is blue color because it's a grown, right? So, that's it. We have wired up the system, and now we have to connect it with the power. Right? So maybe I can obtain the ground here and connect it to this particular ground here, right? And then on the positive terminal, I can obtain it from here and connect it to this particular terminal. So then these are positive, these are negative. Finally step is we have to change the color. Okay. So now we have done connecting the circuit. Now you can notice that I have used only this small amount of portion to connect the circuit. If you have any other circuits, maybe different kinds of switches and resistors, you can utilize the rest of the space here, right? Okay. Maybe you can reduce the size. Maybe you can rotate this resistor and connect it. If you want, you can do that one, right? Okay. So now, what I'm going to do is I'm going to check whether it works or not. So how can you do that? It's very simple, go here and start simulation. So if you do that, so then the system will work according to our desire, right? Maybe if I click this button, you can notice that the bulb is turning on. But I think there is a problem, right? Here. So here I have used the push button. So if I wanted to give the power to this particular bulk. I need to press it, right? So I cannot see what happens to the circuit, right? So I just wanted to notice what has what is the issue, right? So I'm going to stop this particular simulation and get rid of this button, and then I wanted to connect it with this particular resistor. And I wanted to see what is the problem here. Right? If you move your cursor near to this particular LED, on there, you can notice that current through the LED is 20.9 milliampere while recommended maximum is 20 milliampere. The usable lifetime of the LED may be reduced. So then the current that flows through the LED is slightly more than the required amount. So that is what the problem has been arised. So now, what I'm going to do is I'm going to stop this simulation and click this register, and then I'm going to increase the resistance to 350. And then see what happens. Now the problem has gone, right? So now I'm going to stop the simulation and then get rid of this cable and then connect this particular push button like this and click Okay. So now if I press this button and then the entire circuit will work accordingly. So that is the second exercise that we can do this one, right? So hope I have covered the introduction session for the circuit design in Tinker cat Softa. Maybe we will cover more in future. I'm going to leave this particular exercise for you to practice, right? So Example three is for you, right? So you have to connect this particular battery with a switch and an LED bal and another switch for this LD b. So if I press this switch and then this LED will be turned on, if I turn on the switch and this particular LD will be turned on. So that is the object, you have to achieve. Okay. Right? It's very simple. We can do it in the thinker cat Softaa. You can expand this one, right? It's very simple. You can obtain another cable copy and paste this one somewhere else here, and then you can copy and paste this somewhere else here, and then you can copy and paste this somewhere else here, and then you can obtain the positive from here. No need to obtain the power from here, better, right? So because these entire lines are connected together. So then you have to connect this positive to this one and the negative to this cable. Make sure it's on the quickly finish the excise three as well. So if you want, you can practice more and more by adding some more circuits. Maybe you can reduce this one. You can replace this battery and see what happens and you can replace this LED belt and see what happens and you can connect this particular resistor on different kinds of positions and see what happens, right? So like this, you can practice what will happen. If I connect like this, if I don't press this switch, it will be turned on. So it's up to you, you can practice 6. Flowcharts: I told you earlier that the Arduinos are controllers. They control the inputs and outputs, but we have to program them, right? So programming may be hard, right? So it may be hard for you to program. So I wanted to simplify the programming, how you can exactly create an easy visual programming. But the visual programming that the scratch programming may also be difficult for the students to understand how we are to start, how to end them, how we can loop them. Those kinds of problems will arise when you are actually using the scratch programming. For that, I wanted to solve that particular problem as well. Right? For that, we have to understand about the flow charts. If you understand about the flow charts, and then we can easily make that particular visual programmings as well. So it's very simple. We have some symbols in the flow chat, right? So flow chart is an step by step process flow that describes a system or a project. As an example, if you wanted to take the fruits from the fridge, what will you do? Basically, you have to approach near to the fridge, right? And then you have to open the door. If there is any object, if there is any apple or the fruit exist on that particular fridge, and then you can take the fridge and then after you have to close the fridge, and then you have to come back. So that is the process. What happened if if the fridge doesn't have the particular fruit, you have to go to the fridge. You have to approach near to the fridge, and then you have to open the door. If there is nothing exists on that particular fridge, and then you have to close the door of the fridge, and then you have to come back. So this is the flow. Right? So this particular step by step process can be drawn as a chart. It's very simple. We can use some kinds of symbols to actually achieve this particular chart, right? So basically, I'm going to explain about the symbols, right? So this symbol, particularly describes start or end of the process. It's an elliptical shape one, and used to indicate the start and the end. At this start and the end, you should put this particular symbol. These are the rules, right? Okay. Next one, this particular parallelogram is used to indicate the input or the output, right? So you have to define the particular input. Right? As an example, if you are approaching near to the fridge, there may be some distances, right? You have to walk through, maybe 2 meters or 3 meters. You have to walk through. That particular walking distance can be named as x, and that particular distance x will be equal to maybe two or three, right? So whatever we input two meter or three meter, or the robot will travel to that particular distance, right? So that is what we call them as inputs. That particular input will be indicated as this parallelogram. And inside this parallelogram, we have to type them the inputs or the outputs, right? Okay. So I hope you understand about that one. And this one, this rectangular box is used to show an action or a process. Basically, what that happened is this is the main thing, the main task the process that comes along with the flow chart. If you input the distance of the meters, that will come as an input, that will become as paralllogram. But for the walking, right? You are walking. That means that's a statement, or in action. That will come in this category, right? So you have to put a box here, rectangular box, and that will come here. Adding opening the fridge, closing the door, and et cetera. So those kinds of things will come in this particular rectangular shape. And then you have to use some kinds of arrows to indicate, right? So basically, we have to consider the direction of that particular errors, right? It should Adhere to the sequence, right? It should happen one by one. So then you have to indicate where the direction is pointing to, right? And then finally, we have this particular diamond shaped one. So this particular one can be used to decide the decision, right? As I told you earlier, if you are opening the fridge, and then you are checking that. If there is any object or if there is any fruit inside the fridge, you are checking it, right? So if you are checking it, you will have two answers, right? Yes or no answers, right? So if you will go for one decision, if there is no and you will go for another decision, right? So if there is any decision making point in the process flow, you should use this particular symbol. Right. So as an example, if the fridge has fruits, Yes, if it is, yes, you have to take it. If there is no, and then you have to close it, right? So there is no foods in the fridge. So you have to close the door and come back. So the decision for the process will come in this particular one. As an example, is the first number is greater than second number? Yes or no. If it is yes, you can continue this flow, and then if it is no, and then you can continue with this no, right? But You have to clearly mention the yes and no functions. In this arrows. It is not mandatory for mentioning each and every arrow. But in this particular decision making process, you should mention yes and no functions on this particular arrows like this. So that is how it works. We can see some kind of examples. So this is to finding out the area of a rectangle. This example shows that the calculation of the area of the particular rectangle, right? For that, we have to start it from the beginning. So this is the star. And then we have to get the length of the rectangle or we have to measure the length of the rectangle. And then after the length is measured, and then we can get the width of the rectangle or maybe we can measure the width of the rectangle. Those are the two necessary inputs we have to have in order to find out the area. But now, we have those particular two data, two inputs, but we cannot do with those datas if we don't process them. For that, we have to process them, or maybe we have to do some action to that particular data. So that action is multiplication, right? Multiply length and width to obtain the area, right? So we have to multiply them together, and then if we multiply them together, and then it will become as the final area. So that is the output, right? So the find the area is the output, right? So after the area is calculated, and then we can end the process. So that is how the process flow flows through the particular sequence, and then this is how we drove it. Right? So now we have understood about the flow charts, right? So what is the usage of learning this particular flow chart? It's very simple. We have to grab this knowledge and apply it to our robotics, right? So if we are going to do some kind of projects, and then we are going to apply this particular flow chart for them. As an example, if I talk about the flow chart for Sensa deduction, we can draw like this. First of all, we have to start it, right? And I read from Sensa that is operation. You have to do an action, read from the sensa then after the reading is done, let the reading value be x, right? So that means the reading, whatever, the voltage may be five voltage or zero voltage. If it is an analog sensa, the voltage may vary in 0-5 voltages, right? So that particular variable is assigned as x. So that is why I have inserted that as an insert, that means the paralllogram. Right. And then we have to go for a decision. If x is greater than zero or not. If x is greater than zero, if it is yes, and then the LED bulb should be turned on, right? That means if the sensor detects something and then the LD should be turned on. If it is no, it is not greater than zero. That means it is equal to zero, or maybe less than zero, but in this case, we can't obtain less than zero voltages, right? So it will be zero. If this condition is not satisfied. For that, what will result is if it is no, that means x will be equal to zero. That means the sense not recognize anything, and then the LED bulb should be turned off. After that, we are come up with another decision. That is, is there any other readings exist? If there is any other readings, yes, and then we have to read it again. And then the process will be looped. If there is no any other readings available, and then it will end. Right? So that is the process of sensor deduction. So this is a simple flow chart. You can think about whatever the project you wanted to make, and then you can create this particular simple flow chat. If you create this flow chart, it is very, very, very easy for us to create the visual programming. Right? I will explain it to you in our next project session about how we can exactly make those kinds of visual programmings drawn from this flow charts, right? Those are very easy for us to learn, right? So keep triggered. 7. Project No 01 Home Security System: Now, we are going to discuss about the projects. So for the first project, we are going to learn about home security system using a motion sensor. It's a very simple and straightforward. We can do this project by using the Tinker softia and then we will do the programming works, and then we can make this project physically. Let's get started. So this is the aim when the motion sins detects something or the motion, and then the LED bulb should be turned on. If the motion s inside doesn't detect anything, and then the LD bulb will be turned off. So this is the process that we are going to achieve it. But here I'm using an LED bulb instead of using a buzzer for you to demonstrate. But if you want, you can replace this particular LED bulb with the buzzer in order to hear the alarm if you wanted to hear. Right. So here, the motion sensor is there, and then the motion sensor, we have to power it up So we have to obtain the positive terminal from the dino, maybe the five voltage, and then we have to connect it to the VCC pin, and then we have to obtain the ground terminal from the dino and connect it to the sensors ground. And then after we can connect the out of sensor and then connect it to the arduino. So that is how we connect that one. And then the LED bulb is connected on the 13th pin, and then the LED bulbs ground is grounded with the dino. So that is the basic connection. So don't worry. I'm going to connect each of them step by step on the Tinker Cat soft, right? After that, we will make the program, right? So let's open up the TinkerCT soft. And then I have created a new circuit, and I'm going to name this project as project one, right? So here, I wanted to drag and rub some components. So here you can select all. If you want, you can find it from here. And then I wanted to insert a breadboard. The bread board will be inserted here, here it is. Then the motion sensor. We can drag and drop that one. Maybe I wanted to insert like this. Here we can have the three connections here and the du here is the dino. All right. So now you can notice that this particular Arduino is connected through this USB cable, right? So if I click this start simulation, you can notice that the connection is done via this one. So the arduino is primarily powered up by using this cable, right? No worry for the demonstration purpose, whether the circuit will work or not, we have to identify it. For that, we can use the Softare. So actually, what we will do is, we will connect this cable in order to upload the code for the Arduino. And then we will remove this cable and connect the battery with this port or maybe this in port. And then the arduin will be powered up like that. But in the Softa no problem. Right. So this is the connection, and then I'm going to insert some more components, maybe LD valve here. I'm going to drag and drop this LAD here. And maybe if you want, you can insert a resistor as well. But in this case, in the soft tire, you don't necessarily need a battery to perform the task. But if you are doing this actually, you should insert a battery like this, and then you have to connect it to the rbinom. Right? Okay, I'm going to leave the battery blank, right? So those are the things that we have to insert to our workspace, and then I'm going to connect them, right? You know that powering up this breadboard is the final task we have to do. So before that we have to wire these things, right? So here, if you move your cursor near to this particular pin, and then you can notice that what are the meanings of them, right? This one is a signal pin, this one is power, this one is ground. What I'm going to do is I'm going to obtain the power pin and connect it to this particular positive terminal, and I'm going to obtain this negative terminal and connect it to this negative terminal. And I'm going to change the color red and blue. So here I have the signal pin, and then that particular signal pin is connected to maybe the second pin. Change the color to orange. And now I have connected the input wiring. The sensor has been wired up. Now I have to wire this particular LD. It's very simple straightforward. I'm going to take this positive terminal and connect it to this 13th pin. Right? So change the color to red. I can obtain the ground from here. Why? Because the entire line is a ground. If I connect one line from the order and connected to this point and the entire line is ground. Ground is not a problem. We can connect common ground for all the things. It's not a problem, right? So here, I'm going to change this to blue. Right. Now I have connected the output wiring as well. So now after we have ensured that one, we can obtain the power. So this is the power line, so that I'm going to obtain this five voltage. This is an output voltage. If I obtain this five voltage and connect it to the positive terminal of this one, and this is the output from the do we can get five voltage from the arduino, right? So keep in mind that. That will be red color one. And the ground, no problem if you take a ground from here or here, it's not a problem. I'm going to take the ground from here. And connect it like this and make the color like this. Now I have connected the wiring as I desire, right? So that's it, right? You may think that if I start simulation, this will work. You may think that, no. It is not going to work. Why? Because you can notice that the LED is blinking, right? It's not what we have desired, right? And if you click this button, and then this one will appear like this, maybe like some out a bit. So here, if I move this one, that means there is a motion in front of the senza but nothing happens to this LED. The LD is still blinking on and off. It's a problem. Why we have that problem is I'm going to stop the simulation and go to the code. By default, the Tinker softa will write a code for you like this, right? So if you notice that this particular code is for turning on the LAD for 1 second and turning off the LAD for 1 second. That is the code that has been written by default, right? What I'm going to do is I'm going to delete that particular code. So drag and drop that one to the dust pin. So then that code will be deleted. And then if I click this start Simulationatn, and then you can notice that nothing has happened, right? So here, if you move this cursor like this, and the LD is not turning on. Why? Because we didn't program the Ardino yet. I'm going to do the programming, right? So I'm going to do the program very easily if I know how to do the flow chart, right? So I'm going to create the flow chart. I'm going to explain you the flow chart. So if you create the flow chart and then you can easily create this particular program, right? So let me explain that one. Okay right? So this is the flow chart for our project. If there is any motion under the motion sensor, and then the LED bulb should be turned on. So that is the condition. That is the aim that we have to fulfill, right? So we have to start here and read from motion sensor, right? So the motion sensor value, that means it is connected to the second pin of the you know, right? So that pin should be read. Right? So that particular reading should be assigned as x, x is a variable. Let that particular reading value be x. And after that, we have to analyze what is x. What is happening to that particular x. If x is greater than zero, that means That is detecting something. Here, we have here we are using the digital sensor, either we can obtain a zero or one. If it is more than zero, that means it should be one. If x is greater than zero, that means if x is equal to one, This will happen. Yes. If it is yes, turn on the LED bulb. That means the LED bulb should be turned on in this condition. That means if the sensor deicts the LED should be turned on. No, that means this condition is not satisfied. That means x is not greater than zero. So the only one position that the x can have is x is equal to zero. If x is equal to zero, that means the condition, turn off the LED, then the LED bulb should be turned off. Right? So again, whatever it happens, maybe turning on or turning off, we have to look for another readings. Any other readings exist? If yes, and then it will be looped again, read from the motion sensor, and as the value as x, and it will continue. If there is no any other readings available, if it is no, and that is the end of our program. Now, I have explained you the simple flow chart for the process of detecting a home security system, right? It's a very simple and straightforward. You can think that this is as a template for your future project. You have to read from the motion sensor and let the reading be x, right? And then you have to continue, right? So this is the template. You can use this as a template and continue to create these kinds of flow charts. If you create a flow chart like this and then it will be very easy for us to program. Let's do the programming, right? So start, right? Start. We don't have anything to write on the program. Read from motion sense. That is what I'm going to start, right? So reading is an input. So I'm going to go to this input, maybe slightly increase a bit. So it's a digital pin, right? So I have connected to this digital pin, right? So it's a digital pin. Rate from digital pin. That is number two, two is the connected pin of this particular sensor here, right? And then if you go back to the flow chart and let the reading value be x. Right? So that particular value will be x, right? So I'm going to go to this variable and create a new variable. If you don't have any variable, you have to create it, right? And then that particular variable should be named x. Since I have created x already, I'm not going to do that one, right? So this is the variable, right? So you can't drag and rob this variable wherever the place you want, right? Because these are not fitting together, right? In this scratch programming, they should connect each other, right? If you drag and rub like this, they are not going to work. They should be connected together, right? So that is why we have this particular shape and this particular shape. Here you can notice that this is a diamond shape like that, right? So each and every block should be connected together. It's like a building block. So for that, we have to go to the variables, first of all, you have to assign that one. I'm just doing this particular task. Let the reading be x. I'm just doing this. Set that particular x is reading that particular value. That means reading the second pin will be assigned as X. Now I have completed this and this tasks. It's very simple, right? And then after I have to go to this one. So here, it's a condition. If x is greater than zero, and for that, I have to go to this one and go to the controls, and then I have to drag and rob this one. Okay. But actually, I'm not going to drag and rob this one. Instead of that, I'm going to drag and rob this one. Why? Because this has if and L's function, right? I'm going to delete this one, and I'm going to drag and rob this one. So if condition, right? I x is greater than zero, I have to have that particular one, this particular one. If x is greater than zero, so that I can go to this method option and greater than will be stored here, I have to drag and drop this particular one. If one less than one, it's not what I want. I want x is greater than zero. This is what I want. If x is greater than zero, this will happen. Okay. So now we have understood about that one, and this condition is four, yes. If this particular condition is satisfied, this will happen. If the condition is not satisfied and else will happen. Again, you have to go to the flow chart and see what happens. If it is yes, turn on the LED bob. It's very simple. If you want to turn on the LED bab, you have to go to the output terminal, and then you have to go to the set pin option and drag and drop two here. Right? So if you do so, set pin, which pin you wanted to activate if the condition is true? I wanted to activate the 13th pin. Why? Because 13th pin is responsible for that particular L b to be turned on. Right? So I have to set this 13th pin. To high, high means give five voltages. Low means give zero voltages, right? So I'm going to set this as high. And now, if this is not happening, if this is not, yes. That means the sensor doesn't detect anything, this will happen. Turn off the LD. Right? For that, I have to turn off the le if it is Ls and I can simply right click this one and duplicate this block and drop it to here. Then you can notice that set pin 13 two high. No, that is not happen, right? What should happen is it should be low. That means set pin 13 two low. Now again, if you read this particular program again, set x value. That means read digital pin, read the second pin on the do you know what is happening to that particular pin. Okay, let's analyze that one. And that analyze, that means that particular log is assigned as x. If x is greater than zero, that means there is something. That means the voltage or something has happening there. And that means the sensor is detecting something. For that, the LED should be turned on. And if it is else, that means it's not happening. That means the sense doesn't detect anything. The set pin 13, that means this particular LE bulb should be turned off, right? That is what the program says about that one. Okay. It's very simple. After this ends with here and it will automatically look to this one, so that we don't have to consider this one. Is there any readings available? Yes. No, we don't have to consider this one? Why? The scratch program in the Tinkercsfta automatically do this one for us, we don't have to consider this one. So if you wanted to limit that particular one, so you can go to the controls and repeat this task for how many times you want? Maybe this one, right? Okay. So now it's time for test, right here, I can click this one, then it will go but the code is still there. If I click this start simulation button, and then here, nothing has happened. But actually, there is. If I click this button, the sens this is the point, maybe a person. This is a person. If the person is moving somewhere else in front of the Sensa, you can notice that the LED is turned on. That means the program works fine. That is the first project, and then we have achieved that in the software. Maybe you can solve the problem by closing adding a resistor in between this one and just going to do that one. Here it is. Okay. Rotate this like this and connect it to this 13th pin. If you connect this particular resistor on other pins, maybe eighth pin or ninth pin, the program doesn't recognize the change. If you change that one in the program, also, you have to change it. Then only it will work. Maybe I can reduce this one to two 50 and start simulation and change this one. Now it works fine. That is how we achieve this particular circuit. Right? So if you wanted to really make the circuit that I have defined already, you have to delete this particular LED bub. And instead of LED Balb, you have to put a buzzer here so you can drag and drop this particular buzzer. So in the buzzer, this is positive, this is negative, right? So you have to be aware about that one. So this is the positive. So the resistor goes here and this positive connected here, and this is the negative, right? So I'm going to delete this one, obtain a blue color able, and this is the negative, and it should be grounded. Right. So now you can notice that the 13th pin is going through this resistor and comes to here, right? And make sure that your headphones are reduced its sound because it's going to pop up the sound, right? So here, start simulation and if there is any person is there, and then it will be alarmed like this. So that is how the system works. If you want, you can replace many things, right? You can replace the motors or something else, right? So that's it. Now we have achieved the first project, but not finished yet, right? Because we have just generated the software and the codings, right? We didn't do this particular project actually. So if you wanted to make this particular project in real time, what you have to do is, you have to click this code option. And on the code option, you have to go for this one and click this block plus text option. If you click that and whatever the code inside here in this particular blocks, it will be automatically turned on as C plus plus code, right? So now, what I'm going to do is I'm going to copy all of these codes. So this is the code that I require for the ordin to read it. Right? So Ordina will only recognize this particular code, C plus plus coding, right? So this particular C plus plus code, you have to upload it to the ordin. So if you are going to upload the code, what you have to do is you have to have this particular Softaa called as dino IDE. But if you want to upload the code to the dino, it should be in C plus plus language. You can't upload the code that is written on scratch program, right? For that, I'm going to delete the existing code. It's very important. I need to delete that particular existing code and paste that particular code that has been obtained from this one. I need to copy this particular code, and I need to come over here and paste it down here. So this is the code. This is the C plus plus code, right? And this code should be verified firstly. I have to click this option in order to verify here. And you can notice that this is the message. It's currently compiling the sketch, and if it has no errors in this particular code, and it will show you that done compiling. And if you have any errors, and it will be mentioned here in this monitor, after it is verified, and what you have to do is you have to click this particular upload button. That is the button is there for the code to upload. It's very, very, very simple. You have to run this code after it has been completed, you have to click this upload code. And then if it is done uploading, there will be a message indicating that done uploading. If you see that, that's it, and then the code is uploaded to your ordina board. After that, what you have to do is you have to remove the USB cable. You have to remove that particular USB cable from your computer, and then you have to wire according to wiring diagram. You have to physically obtain these components. The sensor, this particular buzzer or ble resistors are batteries, et cetera. You have to physically obtain them all and connect them according to this particular wiring diagram. That is very important. If you change the connection, the program will not going to work. You have to connect them according to your program, and then if you connect them like that, it will work. So you have to go to these tools and choose what board you are using, right? You have to come over here, or do you know AVR boards, and you have to select which board you are using. If you are using Odinoobard, you have to select this one. If you are using Ordino nano, you have to select this one, right? So for that, you have to I'm just using rdinomega so that I can use this particular rdinomegaboard. Then if you go here and you have to select the processor. So this is the processor. It is mentioned on the dino boat. If you obtain the dino boat physically, and there will be this indication of the processor. This is the processor that is mentioned on the dino board. So I'm going to select this one. And here, I have to again go to these tools and see the port option. Here, I don't see any port option. Why? Because I didn't connect the dino with my computer. That is the problem. And now I'm just connecting my rdinobo with my computer. I'm just connecting my dino boat with my computer. Like this. Okay. So now, if I go to this tools option, and let it open. If I go to the tools option, and now you can see here, the port is available here, right? So fifth port Arduino mega. This is the port, right? That shows that okay, Ardino is connected to the computer. This is the port the dino it has, right? So I have to select this one, right? That means I have to configure these three things, board, processor and port. Right? After we have configured that one, the dino is ready to upload the code, and then I can click this upload button, and then now you can notice that it's currently compiling the sketch, and it's uploading the sketch, done uploading. You should see this particular message, right? So done uploading means the program has been successfully uploaded to my dino. If I obtain the components physically or really and connect them according to this particular wiring diagram, and then it will work. But I have a practical problem. What is the problem? The problem is I have this particular arduino, but the dino is not powered up yet. Why? Because I have used this particular USB cable to connect the dino and uploaded the code. After I have uploaded the code, I have removed the cable, right? I have just removed the cable. So then you will be only left with these components. Okay. And what I'm going to do is I'm going to select this particular battery and I need to connect this batters positive terminal to this particular V in. Maybe I can change the color. This particular thing on the physical components. I'm doing this work, right? No need to do this one in this particular software. But this process, I'm doing it on the actual physical components, right? So I have connected the battery. That means the ardino will be powered up. Now, if I do this one physically, right? And then the bulb, this particular turned on LED bulb will be turned on, and then the entire system will work. If I move physically, if I move anything in front of the Senza, the m will be turned on, right? So that is how we exactly achieve that one. Right? So hope you understand about this one. If you have any problems or doubts regarding this one. I'm always available for my students to answer the questions. So if you have any problems or difficulties regarding this one or difficulties regarding finding the installation paths. And if you don't see the port option is still available, even after you have connected the Adinobt, you can ask me. I will tell you how you can tackle those problems, right? So hope you understand about this project, we will meet on the next project. 8. Project No 2 - Object Detection System: Now, we are going to discuss about our second project, which is object deduction system using ultrasonic sensor. So basically in this project, we are going to learn about the ultrasonic sensor, and how they are working and how we can configure them and obtain the job for our projects. Basically, if you don't know what is object deduction system, it's pretty simple and straightforward, and this is the object deduction system. There is the system, and if you move your hand or any object nearby the sensor, and it will detect. That means it will turn on the LD or it will alarm it. So that is the object deduction system. It's basically the similar idea for the working principle of motion sensor, but it's different. Motion sensor will detect the motion. If there is any object present in front of motion sensor, it doesn't dett right? That particular object should move or there should be a motion. If so, that motion sensor will capture it. But on the other hand, in the ultrasonic sensor, this will dedt if there is any object present in front of the sensor. So those are the two differences between those kinds of sensors. And now we are going to use this ultrasonic sensor. So if you obtain an ultrasonic sensor, there will be four pins instead of three, right? So the three pin sensors may work similar. As an example, three pin sensors may have VCC, GND and signal pin. Those are the three pins. But in this particular ultrasonic sensor, you may have four terminals. VCC, GND, copin and trick pin. So those are the four pins you have in this particular ultrasonic sensor. Right? So, unfortunately, if you obtain a sensor that has three pins that will work similar to the motion sensor. How did you wire on the motion sensor? The same wiring will be applied to this particular three pin ultrasonic sensor. But most of the sensors are having four pins. So I'm going to talk about how we can connect them, how we can wire them, right? In this particular project. So before we go to that one, I'm going to explain about the project. So this is the aim of the project, right? If ultrasonic sensor detects any object within 50 centimeter, the LED should be turned on. Otherwise, the LED should be turned off. So this is the condition that we have to achieve it, right? So if there is any object in front of the sensor within 50 centimeter, it should detect. Right? So for that, we have to make the circuit, and then we have to make the flow chart in order to design the visual programming. And then after we have to convert that particular visual program into a clus plus code. And then after we can obtain copy that particular C plus plus code and upload it to the ordinal then after it will work physically as well. But No problem if you practice this particular project in the software, right? But I strongly suggest you to obtain the physical components like the Arduino, sensors, batteries, cables, and connectm. So if you are working on that particular physical properties, physical components, and then you will get an idea and you'll get some experience in this particular course. Okay. So this is the flow chart. I'm going to explain. So first of all, we have to start it. The start doesn't impact on the program, the scratch visual program, right? So read from ultrasonic Sensa. This is what we have to do, right? So the Sens should read whether it has any object or not in front of it, right? And then let the reading value be x, right? That particular value is monitored. Right? And it is named as X. That's a variable, right? After the reading has been set to a variable. What we have to do is we have to find out what is the value for that particular x. As an example, if x is less than 50 centimeter, we have to ask a question. And that particular question will result as okay, there is an object, right? So we have to find out Is there any object present in front of the Senza, right? If it is yes, within 50 centimeter, there is an object. And if it is yes, and then the LED should be turned on. So that is the condition we have to fulfill in this particular decision. If it is not true, the LED should be turned off, that means there is no object in front of that particular sensor. So that particular condition will be fulfilled by turn off the LED bulb. So is there any other readings exist? We have to ask another question, right? If it is no, and that is the end of the program. So if it is yes, and then it will be looked together, right? So then it will go to the initial position of reading the ultrasonic sensor and let the variable be x, and then it will continue, right? So that is the flow chart we can make for this particular project. It's very simple. We can make this particular flow chart. I told you that earlier, read from the sensor, let the reading value be x is maybe a template that you can use, and then you can continue to work according to your projects. So I'm going to make this particular circuit on Tinkercad software, right? I'm going to connect all the components together by using the Tinkercad software, right? Let's move on to that one. So Okay, this is the interface. You have to go to the circuits option, create new circuit. So this is the interface as you know that. I'm going to double click this one and name this as project number two, and I'm going to click these components and make all components available for me. And then I'm going to insert some components or do you know and breadboard, and ultrasonic sensor. So here, this is what I told you earlier. We have two sensors. This is a three pin sensor, and this is a four pin sensor. If it is a three pin sensor, you can achieve very easily, right? It works similar and the connections and the programs are similar on what we have learned on the first project. If it is a four pin sensor and it's different, right? So here we have additional two pins, right? So VCC and ground, those are Okay. You know how to connect them. And here we have trick pin and copin. That is the problem, right? I will use this particular sensor, four pin sensor to complete this project so that you can understand this sensor as well. So I'm going to click this sensor and delete it. Now, what I'm going to do is I'm going to insert the LED bub You can insert a buzzer if you want, you can do that one as well. And I'm going to insert a resistor. Right. Now we can finish up the wiring. It's very simple, you have to connect a sensor like this on the breadboard. You can connect it. After that, you have to connect this particular VCC to this positive terminal, and ground should be grounded on this negative. And then after we will be left with these two pins, trick pin and copin, right? So what I'm going to do is I'm going to connect this trick pin and copins. So the trick pin can be connected to one of these spins. I'm going to connect this on the 12th pin, and the eco pin, I'm going to connect this with the 13th pin. Let's align a bit and I'm going to change the colors. So you know this color will become as red, and this color will become as blue or black. And this color, particularly, I just wanted to change this color as yellow color. And this as orange. Right. So now I have connected the input wiring. That means the sensor has been connected completely. And then after what I'm going to do is I'm going to connect this particular output. I told you earlier, we have to use a small portion of the breadboard, right? So make sure that you adhere to that particular tips and tricks. And I'm going to connect like this and obtain this particular bulk and I'm going to rotate it and connect it like this. Right? And then this connection, right? So it will go to the position where I want to connect this with the eighth pin of this ordine. And make it as red colored wire. And then I wanted to ground this, right? So here, I have grounded this one, change the color. Okay. Now I have finished the output wiring as well. So what that means is I have completed the wiring, but not yet. So here I have to connect the power with this particular pin. Then only the system will work, right? For that, I'm going to obtain a five voltage from here and connect it to this particular pin and change the color to red. And then I have to obtain the ground and connect it to this particular pin and change the color to blue. So now I have finished up the wiring, and then it will work if I code it, right? So I'm going to make the coding. It's very simple in the scratch programming. It's very simple for us to make the program, right? So let me delete this one. Okay. So if you click this code option and you can expand this one to see this one. And then you can delete this existing code, and we have to head over to our flow chart, right? So this is the flow chart. And according to the flow chart, we can make that particular program for our project, right? So I'm going to do that, right? Here, read from ultrasonic sensor, read from ultrasonic sensor will become here, right? So in the input, read digital pin, right? So this is what we have insert in our project number one. But here, I'm not going to do that one. Why? Because for the ultrasonic sensor, we have a predefined function in this particular Tinker cat software is this one. Right? For that, I'm going to drag and rub this one. This one is an special case for sensor reading for the ultrasonic sensor. Here you can configure that read ultrasonic descent sensor on trigger pin. Which pin you have connected the trigger, right? So I have connected this particular trig pin. This is the yellow color cable, and if I track this yellow color cable, it's on the 12th pin, right? So I'm going to select the 12th pin. And here, echo pin. Here, the echo pin is connected with the orange color cable, and if I go here, right? So this is the orange color cable, and it's on 13th pin, right? I'm going to select the 13th pin here, right? So if you use that particular three pin censor, you should select this option, same as trigger option. If you use the three pin sensor, you should use that one. But I'm using four pin sensor, so that I'm going to configure tri pin and copin Right? So then after you can change the units, right? I'm going to go with the centimeters. And then if you go back to our flow chart, let the reading be x. Okay, this is the sensor reading, right? So the 12th spin and 13th pin are monitored together. Right? But we didn't set any kind of variable, right? That will be monitored, but that particular monitored log should be assigned as a variable, right? So that's what I'm going to do now. Let here you can notice that. Let the reading be x. Right? So for that, I'm going to go to these variables and create a new variable and name it as X and click Okay. So then you will have these two options available for you to configure, right? So for that, initially, I'm going to drag and drop this one. Set, set X two, this one. Right? For that, I'm going to drag and drop this one into this one. So now if you read this one, set x two, read that particular 12th spin and 13th spin, right? So the 12th spin and the 13th spin are monitored together, and that particular one, that means the distance will be named as x. Right? So that is what we have done so far here. And then after we have to make a decision. X is less than 50 centimeter, if it is true or false. So for that, what I'm going to do is I'm going to go to this controls option and drag and drop this particular F and function. If only happens if function, you can drag and drop this one, but I have function and L function as well, right? If it is true, this will happen. If it is full, this will happen. So I have two conditions. So that I have to drag and drop this particular one, right? So I'm going to delete this one and go with this one. Right? So here, you have to go back to this flow chart and see what has happened. Right, x is less than 50 centimeter, right? For that, you have to check that particular x value. How much is the x value, right? So for that, I'm going to go to this metoption and drag and drop this one into this one, right? So here, what I'm going to do is I'm going to go to these variables and drag and drop this particular X. So that, what will happen is. So Okay. What will happen is if x is less than one, this particular program will happen. If x is not less than one, this particular program will happen, right? So this is not what I want, right? I wanted to have 50 centimeters, right? For that, I'm going to type 50. Why? Because the x is already in the centimeters, right? So no need to configure the centimeters here. So if I set this x already in centimeters, I can type the value here, so it will automatically adhere to this particular unit. Right? So if x is less than 50 centimeters, this will happen. What will happen? You have to go back to this flow chart, and this will happen. Turn on the LED bad. You know how to turn on the LED bad. You have to go to this output tab and drag and drop this particular one into this one. So then they can be fitted together. And that particular able is connected. The positive line is connected with this particular eighth spin on the din. So for that, I need to select eighth spin to means it will be turned on, right? So this is what will happen if this condition is true. So again, go to the flow chart. What happened if it is false? If it is no, it should turn off the LED, right? So then the Ls condition will happen here and I'm going to duplicate this one and drop it here, and the eighth spin, that is the pin I have connected the LED bulb with, and I'm going to change this high to low. That means if this is not true, this will happen. Okay, that is the program. And then this program will continuously run forever until you disconnect the power, right? So let's check it whether it works or not, right? So if I click this start simulation, and it will be started the simulation. If I click this ultrasonic sensor, this is the object, right? So you can notice that how much is the distance between the object and the sensor, right? So if I move this particular object near to the sensor. Okay, it's nearly 70, and I'm just getting closer and now you can notice that this LED bulb has been turned on, right? So What else do we have to do. If I move this one far away, and then the LD bulb will be turned off. So here, I purposefully did two mistakes, right? Can you identify and say it? Right? I have done two mistakes purposefully for you to understand. Can you just guess that one, right? One mistake on this particular flow chart, and one mistake on this design, right? We'll see who will answer that particular one. Okay. The first mistake is this one. Let the reading B x. This is an input. I'm just inputting that particular variable, right? So this will be a parallelogram, right? I cannot drag and b. This one, I need to insert a parallelogram. So I should have indicated that particular parallelogram, like this. This is what will come here. And the second mistake I made on this particular design is the resistance. The resistance value, I didn't change that one. The resistance value may be 250 for the LED bulb to be brighter, right? So if you stop simulation and start it again, and if you move, now you can notice that the LED is turned on as a brighter one. Those are the two mistakes I have made, and that is all about this particular project. Now we have achieved that particular project in the Tinker CAD software. Now, what we have to do? What we have to do is we have to upload this particular code to our physical arduino, right? So then after we have to connect all these things together, and then it will work fine. For that, I'm going to go to this code option and go to the blocks and select block plus text option and select all of the codings. I need to select all of this coding and copy this one, Control plus C. And then I have to minimize this tab and open up the installed Arduino Softa on that particular Arduino softia, the C plus plus code has been obtained from Tinkercad Softa and that code should be pasted on this particular Arduino softia then after you can upload this code. But keep in mind that when you are uploading the code, you should connect the ordino with your laptop or PC or even you can connect the dino with your smartphone, but you have to have an OTG cable or OTG pin to connect the dino and your smart phone. So those are the necessary things you should have if you wanted to connect and upload your codings. Right now it has come. Now I'm going to selch all the codings, and I just wanted to save the sketch, right, save it as on the desktop. I can save this project as project number two and click the save option. And I'm going to paste my code that has been copied from the Tinkercad soft dare. And now, what I'm going to do is I have to click this upload, but no. Before I click that plod button, I should go to the tools option and select which board I'm using. Every time even you are doing the project, you should select this one. You should configure them one by one, right? These three things should be configured by you, each and every time when you are uploading the code, right? So you have to make sure that it is set to perfect, right? So then you can select the board, what board you are using and which processor you are using, and then the port, right? So if you wanted to have the port available for you, you should connect the ordino with your computer, and then the port option will be available for you, right? After the port is also selected, now you can click the upload button, and then after the code will be uploaded to the dino. If I click this upload button, now you can have the error. Why? Because the dino board is not connected with my computer. Right? So that is the problem. And after the code is successfully uploaded, you will have the message of done uploading. And after you have received that particular done uploading message, and then you can connect the circuit that has been designed on this particular Tinker cat softia have to obtain the Arduino and a sensor resistor and the L and breadboard, and then you can connect them like what you have done so far in the Tinker cat softia and then the project will be made on physically as well. Right? So hope you can do that one. So the physical things will be up to you. You can practice, and you can creatively make some kinds of things, right? You can arrange it in a box. You can design an enclosure, and you can add some features, right? You can make a haul for the ultrasonic sensor, and you can cover the internal parts and you can creatively make this project, right? It's up to you. All right. So I'm going to end this session of the project number two, and we will meet on the project number three. 9. Project No 03 - Smart Dustbin System: Now, we are going to discuss about our third project, which is smart dustbin system using ultrasonic sensor and servo motor. In this particular project, we're going to learn about the usage of servo motors, especially, right? So before we get to know about the technical things, we want to show you that how the system works, right? So what is actually the smart dustbin system is, right? I'm going to show you this particular video, this was obtained from my previous students. So they did this automatic smart dustin system. And here you can notice that, right? If I move my hand close to the sensor, and then the lid will be automatically opened up, right? And then we have to put the dust into the bin. And then after we put that particular dust and then it will automatically close the lid. So this is how it works. I want to show it to you again. Right. So in this particular process, how the system works, right? So I have attached a ultrasonic sensor and a sero motor and some kinds of albino bras in the electronics, right? So this was my student's work, and he did like this. So if you want, you can change the design and change everything And for the first time, we have to learn about this one, how the system works, how we can rotate the servo motor, how we can control them. What are the theories behind this? So we have to get to know about those things, and then we can change the design if you want. So here, in this particular example, if I open up another one, this was my second project from my student. Another student did this one. So this one is also similar to that one, right? So if we move our hand near to the sensor and the lid will be automatically opened up, and after 4 seconds or maybe 3 seconds and the lid will automatically close, and the lid will be automatically closed, right? So that is how this particular system works. So it's called a smart Daspin system, right? So this is what we are going to exactly make it. But for the physical things, it's up to you. You can create different kinds of physical things according to your creativity. What I'm going to do is I'm going to explain you how you can create this and design this, how you can program this and upload the to the ordinu. That's what we are going to see in this particular project. Let's get started. Here, aim of this project is we have to design a smart test bin system. In order to achieve this particular aim, we should follow these objectives. First of all, if the ultrasonic sensor detects any object within 30 centimeters range, and then the Svomtor should rotate 180 degrees. So if your system, if your design is for 90 degrees, you can change this to 90 degrees. It's not a problem. So the next one, the servomotor should stay at 180 degrees to insert the dust into the dustbin. Okay, this is the servomotors initial position, right? And then the lid is connected with this particular ser motor like this. And then if there is any object present in front of this ultrasonic sensor, and then the lid should be opened up. Right? So then this particular servo motor will rotate 180 degrees, right? And then the lid will be opened up. So then we can insert the dust into this particular dustbin. And then after it should stay in this position. That means the opened position. It should stay in the open position for 4 seconds. Why? Because we assume that four second is sufficient for the dusts to be inserted into the dustbin then after it should return to its initial position. That means it should return to zero degree, right? So that is what it should happen. So in order to achieve this project, we have to follow these kinds of steps. First of all, we have to create a flow chart. If you do so, it will be very, very easy for us to create the program. And then we have to design the circuit in Tinker Cat software. Then after we have to develop the scratch program using our flow chart. We can easily generate the C plus plus code from the scratch program by using the Tinker Cat software. And then after we can connect the actual circuit with the Arduino and other electronic components to make the circuit. So then we can upload the code into the ordinal, and that's it. The project will work, right? So let's analyze about the flow chart. So here, we have to start it, right? And then after the particular ultrasonic sensor should read. The pins, right? So read from ultrasonic sensor is the first objective. And then the reading that has been obtained from the ultrasonic sensor is named as x. That is why let the reading be x is there. We assign a variable called as X to that particular sensor reading. And then we have to analyze what's happening to that particular x variable. And if the x is less than 30 centimeters, what should happen? That means if the x is less than 30 centimeters and we have neared our hand from the sensor. That means the x is less than 30 centimeters, right? So we are near to the sensor. That means the servomotor should rotate. Therefore, if it is yes, that means if the condition is true, and then the servomotor should rotate 180 degrees. If it is no, what should happen? If it is no, nothing should happen, right, or the servomotor should stay at its initial position. Let's talk about yes, right? So if we near the sensor and the motor should be turned into 180 degrees, and then after it should stay at 180 degrees in order to put the dust into the bin. But there should be a duration, right? So there should be a time duration of 4 seconds to insert the dusts. And then after The server motor should return to its initial position. That means it should turn to zero degrees. And then after the process we'll try to continue it. And if it is no, that means if it is not true. That means there is no any other object or hand near to the sensor right? So then it should stay its initial position, right? So that is why I have connected the no condition to here, right? And now we are going to design the circuit, right? It's very simple and ECD do that one, right? So let's talk about that particular circuit in the Tinkerct software, right? I'm going to go to the Tinkercad soft tire and click this create new circuit. Right. So before I insert the components, I just wanted to explain you how the servo motors are working. If I type motor, and then you can notice that there are several kinds of motors are available here. And now I wanted to drag and rob this particular gear motor and a servo motor. Okay. So these are two different kinds of motors, right? So this is called as a DC motor, right? So what will happen to this particular DC motor is if I supply the positive terminal, I have to obtain a battery. Maybe a nine voltage battery. If I connect this positive to this particular positive and the negative to this particular negative, what will happen? What will happen is and then this particular motor will try to rotate in clockwise direction. Right? And if I change this particular terminals, like if I delete this cable and if I disconnect this cable and connect it to this negative. That means if I change the connection, if I alternate the connection, and then you can notice that it's rotating in counterclockwise direction. That means the -280 6:00 P.M. Right? So that is what will happen to this particular DC motor. But the servo motors are different, right? If you move closer, and then you can notice that it has a grown pin and a power pin and a signal pin, right? So this will work as a sensor module. It will work as a sensor module, but this is an output device, right? So first of all, in order to get the job done from this particular servo motor, you should power this up. So to do that, we have to supply the positive terminal to this particular power. And then we have to supply the negative voltage, that means the ground to be ground to this particular ground. So if we do so and then the motor will be powered up, but it's not going to work. Why? Because the position, right? So the rotational position is controlled by this particular signal pin. So if I supply, maybe let's say that we have a zero to five voltage, right? And if I supply five voltage for a particular amount of time, and then the motor will rotate for that particular time. If I increase that time and the rotation will be also increased. That is what will happen, that is called as PWM control. We will talk about them later. And if I connect them with the analog pin, As an example, if I supply three voltages. The three is in 0-5 voltages. If I connect that to particular analog pin and supply three voltages, and then it will try to rotate some amount of degrees. That means the portion of three voltages. Right? So that is how it is controlled by this particular signal pin. If I supply 2.5 voltage, and it will try to rotate 90 degrees. So this will not continuously rotate. It will position the thing in 0-180 degrees, more than 180 degrees, it should not rotate, right? So that is how the servomotors are working. And now, I'm going to name this as project number three. Three. And I'm going to drag and rub the components like how do we know bread board. Servo motor, ultrasonic sensor. I'm going to go with this particular four pin sensor. I'm going to attach it with this particular pins. I wanted to insert a battery, but in the Softaa we don't necessarily need a battery. Why? Because we currently use only one servo motor, right? So the dino has the capability to supply the voltage to this particular servo motor. It's sufficient. But if you use two or three servo motors, and the power that has been obtained from the dino is not going to be sufficient. So for that, you have to use an external power supply to power up this particular servomotor. As an example, you may use a battery, six voltage battery or five voltage battery to supply the power to this particular servomotors, right? If it is one, it's not a problem. Right? So, since we are using only one servo motors, it's not a problem for us, right? So I'm going to connect them all. So it's very simple, obtain a red color cable and connect the VCC to this one and obtain a blue color cable. And connect the grow to this particular grow. Now I'm going to wire up this particular trick pin to whatever the pin I like. I'm going to connect this particular pin to the tenth pin. And the eco I'm going to connect this with 11th pin. Maybe change this color to yellow. Okay. I hope you see this one. Okay. Okay. Now I have finished up the wiring for the input device, and now I'm going to connect the output device. Here, I told you that the servo motor should be powered up, right? So that I'm going to obtain the power from this particular positive terminal. I'm going to obtain the power from here because I told you that we have to use the minimum space. So that it should be connected to this particular positive terminal here. And then I have to obtain the ground from here and connect it to this particular grow. So this is the grow, right? And then I have only one pin left with this particular motor, right? So here, you can obtain this particular signal pin and connect it to. One of these pins, right? So if you do so and then you will only be able to control this particular servo motor either zero degrees or 180 degrees. So if you wanted to control this particular servo motors in between the degrees and it's not possible. Why? Because these are digital pins. So what I'm going to do is I'm going to connect this particular serve motors pin to the analog pin, right? So in the analog pin, I can connect from these pins. I'm going to go with this node pin and change the color to orange. And that's it. Now I have connected the entire system. And then after I have to connect the power to this particular bed board, and then the power will be distributed from there, right? So I'm going to do that one quickly. Now the system will work. So if you wanted to obtain this particular system working, what we have to do is we have to do the programming work. Programming is a very easy thing. No need to worry about the programming because we have already drawn the flow chart. So I'm going to click this code option and delete the existing code here and I'm going to expand this a little bit. And So now, what I'm going to do is I'm going to open up the flow chart. In this flow chart, read from ultrasonic sensor. That is the first thing I have to program, right? So I should read what's happening to that particular sensor. Right? So that will be obtained from this input, and I have to insert this one. Why? Because this is the responsible block for that particular sensor, right? So I need to go here and check where I have connected. The trick pin is connected to the tenth pin, and the copin is connected to the 11th pin, right? So I'm going to configure it here. So the trick pin is connected to the tenth pin, and the copin is connected to the 11th pin. And I'm going to keep this in centimeters. Now, I need to open up this particular flow chart again and see what happens. And then offer, let the reading be X. I need to assign a variable for that particular log. This is the value, collection of data, and then I need to assign a variable for that particular data at each and every instance, so that is what we call them as variables. For that, I need to go to the particular variables and click Create variable. I'm going to name this as X and click Okay. So now you have these two options available for you? I have to select this one if you are initially setting up the variable, right? And then after I have to deck and drop this one to this one. Then if you read it here, set x two, read ultrasonic distance sensor on trigger pin ten co Pin 11. That means it will notice what's happening to that particular sensor, right? Is there any object percent right? So if there is any object present and that particular distance will be calculated and that distance is equal to x in centimeters. That is what that particular meaning of that one. Right? Again, if you open up this particular flow chart, and then you can notice that I have to have a condition, right? That is a control. And then after I need to analyze what's happening to that particular x, right? So if the x is less than 30 centimeters and the servomotor should rotate, right? So I'm going to write that particular condition. So that is from here, and I'm going to drag and drop this one. Since I have function and function, right here, I need to insert the meth condition to here. That particular condition is here, x is less than 30 centimeters. I need to check that one. For that, I'm going to go to this meth option and drag and drub this particular one because this is the block that has this particular symbol, that is less than or equal that particular condition. Okay. And then it's not what I expect. One is less than one. This is not what I want. What I want is I have to go to these variables and drag and drop this particular x, and that is what I want. So if x is less than one, no. That is also not I want. What I want is I want this to be 30 centimeters. If I type 30, that will be enough. No need to type the units. Why? Because the x is already defined in centimeters. So we don't have to define this particular 30 also. It will adhere to this particular units. So if you want, you can change this to 50. That means it will open up the lit if it detects within 50 centimeters. I'm going to go with this 30. Right? And then if this condition is true, right? So I have to go back. If this particular condition is true, if it is yes, and then the servomotor should rotate 180 degrees, right? For that, I have to go to this particular output option. On there, you can find out the servomotor option. Right? So here, I have the servomotor option, rotate servo on pin number, which, right? So you have to configure which pin you have attached that particular servomotor, right? And I'm going to go back to this one, and here, the signal pin is connected to the node pin in this doing. That I need to configurate. I'm going to click this one and select the Note pin. If I move it here, you can see that one. Note pin is the pin that has been connected with the motor. Then it will ask you to select how many degrees you wanted to rotate your server motor. If you set your design for 90 degrees, you should select that one. If you set your motor to 180 degrees, you should select that one. But more than that one, you can't obtain. Why? The cell motor is only limited to 180 degrees of rotation, right? So I'm going to go with this one, and I need to drag and drop this particular block into this one, because if it is true, this should happen. Right? And again, if I go back to this flow chart and see what happens after that one, right? So after the motors rotation, it should stay at 180 degrees for 4 seconds. That means in this particular rbino, it will supply this voltage for this particular motor at a very minimum amount of time, maybe 0.0 1 second. Right? So what I'm going to do is I'm going to state that particular voltage for a particular amount of seconds, right? For that, I'm going to go to this code option and go to this controls option and drag and drop this particular one and make it as 4 seconds. So here, this should come after this one. If you put this one before this one and it will not going to work, right? That particular voltage, whichever the voltage you supply to keep that motor in 180 degrees, that should be stayed. Right? So it should stay for 4 seconds. So what should happen after four second ends? I need to tell to the computer, Okay, computer, you should do this after 4 seconds, right? So I need to find it out from my flow chart, right? After four second ends, it should come to its initial position. That is what it should happen, right? So for that, I need to go back to this particular output option and drag and rob this particular one. Or maybe I can duplicate this one, and drop it here, and I just wanted to delete this one. So here I need to drag and drop this one, but I need to configure it to zero degrees. Rotate servo on pin ode to zero degrees. And then whatever the motor is connected in this de pin, that particular motor rotate to zero degrees. That means it should come to its initial position, right? So I'm going to drag and drop this particular one below here. And then after, I need to configure what should happen if it is not happening. That means if x is not 30 centimeters. It's not detecting anything. That means I need to configure that as well, right? So if it is not happening, and then the server motor should return to its initial position. That means rotate servo on the de pin, and it should stay at zero degrees, no changes in the motor. That is what should happen in this particular motor. Right? So that is how we can code the system, and see whether the code is working or not. So now if I start this simulation and you can notice that what will happen, right? So I'm going to click this one. Now you can see that 185.5 centimeter is there. And now if I move this one particularly closer than this one and take it away. And now you can notice that the motor has been rotated to 180 degrees and after 4 seconds, it's returning to its initial position. But now you can notice that the returning is very, very slower, right? So in order to solve that particular issue, what I have to do is I have to go to this particular code option and go to this control option and I need to drag and drop this particular one below here. And I need to say that motor, and for the time it should take maybe 0.5 or 1 second, right? So you can type 1 second, right? And then you should copy this one and paste it down here. You should put this one as well, because for the motor to rotate, it will take 1 second, so then it will be configured like that. And if I start the simulation, now it will work fine. If I click this mark, and if I move this closer, and then if I take it away, now it will rotate after 4 seconds and it will come back. That is how we exactly make that particular project. That is the code, right? So then after what we have to do is I have to go to this particular block plus text option and select all the codes, right, and control plus copy. And then I need to open up this particular arduino software to upload the C plus plus code, right? And you know how to upload the code, right? So we have to configure which port the dino has been connected to, and then you have to select the particular Arduino board. And then after you can upload the code. Right? So before you upload the code, make sure that the code the dino is connected with your smartphone or your computer, and then you can upload the code, right? And also, you should make sure that the other external power sources, right? That means if you are connecting your dino from the USB cable, and you should disconnect the other external power supplies. If you supply the power to the ordino from a battery, and then you should disconnect that particular battery, right? Then after you can connect your dino and your laptop by using the USB cable, and then You can upload the code after the code is successfully uploaded, and then you can remove the USB cable, and again, you can connect the dino with your battery, right? So I'm going to go with this new option, and I'm going to delete the existing code, and I'm going to paste that particular code that has been obtained from TinkerCAD software, and I'm going to name this project. I'm going to save this one. As project three, and I'm going to go to this particular desktop and save it. Now you can click verify and upload. Before you upload, you should configure these things, the board processor and the port, right? And then you can upload the code after you have successfully uploaded the code, and then you can wire the system according to your wiring here, and then it will work. Right? So I will upload the codes and the study materials and the nodes here in the course, right? So you can find them out, and then you can work on this particular examples. And now you can change the values, right? So you can change it to 90 degrees and change the duration, and you can connect obtain another motor, and you can expand it. I just simplified everything and taught you, right? Now, what you have to do is you have to practice the same thing, what I have done so far, right? You have to practice the same thing. Follow my steps, And then after you have successfully achieved our project of this one, what I have achieved. Now you can expand your creativity. Now you can explore your ideas. You can connect maybe two SensRs, you can replace the Sensar and you can connect two motors and now you can expand it. First of all, you should understand how they are working by following my step by step guide. And then after you can practice whatever the thing you want, right? So that is how my students were practiced before. So let's mate on the fourth project. 10. Project No 04 - Obstacle Avoiding Robot using L298N Motor Controller: And now we are going to discuss about our fourth project, which is obstacle avoiding Robot using L 298 motor controller. And this is an easy motor controller. That is why I have used that one. It's very easy to learn. And before we get started about the project for the technical things, I wanted to show you how the robot is working, right? And before projects, we have learned about the systems, and now we are going to learn about mobile robots. That means it's a movable robots, right? So here, I'm going to show you my previous students homeworks, right? So this is a obstacle avoiding robot, and you can notice that how it is working. So it's the robot. If we turn on the switch, and then it will move. If there is any object present in front of the robot and it will rotate in right direction. Right? And if there is another object present in front of its light and it will rotate in right direction. So that is the condition that the robot has. This is also a obstacle avoiding robot. I'm going to explain you the simplified version of the robot, and then you can combine what we have learned in our previous projects, maybe the Smart Despin system and the home security system. You can combine them all, and then you can make a robot like this, y? Because this robot, particularly, contains an obstacle avoiding robot, and as well as what we have learned in our project number three. It has a servo motor as well and a ultrasonic sensor as well. So you can combine them, right? So before, We have learned three projects, right? And altogether, we will learn five projects, but it is not limited to, right? You can make tons and tons of projects if you understand the working principle of the sensors and the motors and the devices, right? So that is what we have to do, right? In each and every project, we have to understand about their working principles, and then we have to apply it on another projects. So that is how the obstacle avoiding robot works, right? So it should move in forward direction if there is any object present in front of that particular robot, and it should turn in right direction. So that is the condition it should follow. And then the components that we need in order to make that Arduino jumper cables, breadboard, l298 motor controller, gear motors. You can obtain two motors or four motors. It's up to you and a car chassis free wheel, battery, nine voltage or 12 voltage, you can obtain, but it should be a rechargeable one, right? Because the charge will be quickly discharged. So then you should use a rechargeable battery. And you have to use ultrasonic sensor to accomplish the task of obstacle avoiding robot, right? Okay, now we are going to understand about L 20098 motor controller, right? It's pretty simple and straightforward. So why I use motor control? I can directly connect that particular motor into dino. So why I have a motor controller. Right? So basically, the problem is the DC motors, these motors are requiring more amount of current to be flown through them in order to work, right? So that particular required amount of current will not be drawn from or dono. So for that, we have to use an external power source or battery to power the motors. But if you directly connect that particular battery with your motor, what will happen? It will continuously try to rotate. If it's rotating, we cannot control them, right? So according to our desired position, we need to control the rotation of that particular motor. All right. And the second option why we use this particular motor controller is here, we are not using a single motor. We are using two motors combined together, right? So that particular two motors should be controlled to obtain the motion in A direction, backward direction, left and right directions. Right? So to control everything up nicely. That is why we use this particular motor controller, right? So now I'm going to explain about the terminals. If you obtain this particular motor controller, and here you have the 12 voltage pin, right? So in this particular 12 voltage pin, you should connect this with the batteries positive terminal, right? You should obtain a 12 voltage battery or nine voltage battery. And then the positive terminal should be connected to this particular motor controllers, 12 voltage pin. And then after you have to obtain the batteries ground and connect it to this particular ground on this terminal, right? So you can use the shot driver to connect this app. And then after you have another terminal called as five voltage terminal. Why we have that particular five voltage terminal, right? So that particular five voltage terminal is to give the power to the terminal. It's not an input. We cannot input any voltage to this particular one? It's an output voltage, like in the rdinos five voltage. It's an output voltage. Why? Because we are connecting this particular battery. Let's say we have only one battery, and then that particular battery is connected to this particular motor controller. And then I wanted to connect the Arduino to be powered up as well. So how can I power up That is why I have this particular five voltage terminal, and then it should be connected to the dinos pin. It's dino, right? Okay. It's dino Ordino pin should be connected from this particular five voltage pin. Is that enough to power up the dino? No, I should connect the ground terminal as well, right? So that I have to obtain another cable. I have to attach another cable into this particular hole, and then I have to connect that particular one to here and connected to this ordinoGND pin on the power pin, right? If I do so and then the dino will be powered up. Right? So each and every device should be powered up before we get the job done from that device, right? So first of all, I have powered up this device, this particular motor controller. And then from the motor controller, I have obtained the power to supply the voltage to this particular dino. Now the dino is also powered up. Right now we have the pins out one, two, out three and out four pins. Why we have those pins? Those pins are responsible for the motors to be connected, right? So this one should be connected to this one and this one should be connected to this one. Likewise, for the left motor, you can connect for right motor as well, right? So this one should be connected to this one, this one should be connected to this one, right? So now I have connected the right motor as well, right? And then after what you have to do is you have to check whether the motors are rotating in the desired direction. Why? Because in this particular robot, right? You have connected the motors with this particular motor controller, right? So when we supply the power, right? So this motor should rotate in this direction, this motor should rotate in this direction. That means the clockwise. So then only the robot will move in forward direction. If you wanted to turn this particular robot in right direction, what you should do. What we have to do is this particular motor should rotate in forward direction while this motor should stop. Right? That means this motor should rotate in this direction for what direction while this particular motor should be stopped. If it is the condition, what will happen? It will try to rotate in this direction about this particular point, right? And if you alternate that one and this motor is not rotating and this motor is rotating. What will happen? And then the entire robo will turn in this particular direction. That is how we achieve forward motion, right motion, and left motion. So what happened if you wanted to achieve the backward motion? For that, you should supply the voltage in reverse direction. That means this motor should rotate in counterclockwise direction, and this motor should also rotate in counterclockwise direction. So then early it will work. So here, if you come back to this one, you can alternate out one to this one, this one. Likewise, you can alternate the connection. But how can you alternate that one? You have to ensure that one, whether it is correct or not. So if you wanted to ensure that the connection is right or wrong, what you have to do is we have to understand about these pins. This is called as the first pin is enable this particular pin. But if you move closer, that means this particular black color terminal. It is called as jumper pins. So this pin and this pin are connected together. And this pin and this pin are connected together. That means enable A and enable B are short circuit. Because for the enable A, this one, the five voltage, this is a five voltage line. This five voltage line is connected to this one. And here also, the five voltage line is supplied to this particular enable B pin. That means What will happen is these motors will rotate in its maximum speed. So if you wanted to control the speed of that particular motors, what you have to do is you have to remove the enable enable BPN. You have to remove those jumper pins and connect it to a lesser voltage than five voltage, right? So how can I do that one? For that, I have to connect with the Arduino and supply the desired voltage, maybe two voltage or three voltage or four voltage, according to the speed that ti require. Right? So those things will be discussed later. Now I'm going to talk about the in one in two in three and four pins. Those pins are here, right? So those four pins are responsible for the motor to control the direction, right? So if you supply five voltage to this particular in one pin, and you supply zero voltage to this particular in two pin, what will happen. This left motor will rotate in for direction. Right? And you supply five voltage to this in three pin and you supply zero voltage to this in four pin. What will happen is the right motor will rotate in clockwise direction. All right. So if you alternate that one, right? So in this chart, you can understand them very clearly, right? So if you wanted to obtain those two motors to run in forward direction, what you have to do is, right? So this is the robot, let's say, you have a tire here and the motor two motors here, right? So if you wanted to obtain the forward motion, this motor should rotate in clockwise, and this motor should also rotate in clockwise. For that, in one should be high, I one should be given five voltages, and in three should be given five voltages, right? While these two pins in two and in four pins should be low. That means it should be given zero voltages. So then this motor will rotate in this direction. Right? So if you want this robot to be running in backward direction, right? So the connection should be reversed, right? So it should rotate in counterclockwise. It should also rotate in counterclockwise. So then in one should be lower while in two is high. And in four should be high while in three is low, right? So that is how we achieve the backward motion. And if you wanted to turn this robot in right direction, what you have to do is you should not rotate this motor, right? And you should rotate this particular motor in forward direction. Right? So the left motor should rotate in forward direction while the right motor is stopped. That is the condition. So how can you achieve that one? So that one should be high while in two is low. Here, don't changes. No changes, low and low. That means this motor is stopped. Right motor is stopped. So this is for right motor. And this is for left motor, right? So you should understand that one. And the left turn, if you want this robot to be turned in left direction, what you have to do is this particular motor should be stopped while this motor should be running, right? So right motor should rotate in forward direction, this motor, while the left motor is stopped, right? So then this motor is stopped. This is the left motor, and this motor should rotate in clockwise direction, move forward, right? Okay. So then it should be high in three should be high, and in four should be low. Right? So that is how it works. And if you wanted to stop that one and both the motors should be stopped. So that is the condition, right? Okay. Now we can talk about our aim, right? We have to design an obstacle avoiding robot, right? For that, we have to achieve these objects, right? So if ultrasonic sensor detects any object within 30 centimeter range, the robot should turn right direction, right? So this is the arrangement of that robot, right? So Here you can have the ultrasonic sensor here, and the motors are there and the gina and all the stuff there, and it should rotate if there is any object present in front of the Sensa within 30 centimeters of range. If the sensa doesn't detect any object within 30 centimeters range, and then it's free, then the robot can move in for what direction. Why? Because there is no obstacles out there. And then the steps. These steps are similar, what we have learned in our previous project. We have to make a flow chart and design the circuit, develop the program, generate the C plus plus code, and make the actual robot and upload the code. Now I'm going to talk about how the robot is working, right? I wanted to show you a video that how they are working. So then you can get an idea and understanding about that one further. Now, we are going to draw the flow chart for this particular system. It's very simple. We can start and read from ultrasonic sensor. That particular ultrasonic sensor in the front of the robot. Should read the reading, right? And whatever the reading, that particular reading should be assigned as a variable called as x. And then after we should check how much is the x, right? So if x is less than 30 centimeters, and that means the sensor is detecting something within 30 centimeter. All right. So then the robot should turn right. If it is yes, right, the robot has to turn. Why? Because there is an object in front of that particular sensor. So what happens if that particular condition is false. So that means x is greater than 30. If it is x is greater than 30, that means there's no object to block the path of that particular robot, right? So then the robot can move forward. So that is why in the no condition, the robot should go forward. After that, is there any other reading available? We have to check that one, right? If the reading is available, and then it will be lot again, is there any other readings available, and that is the end of the program. So that is the basic idea of drawing this particular flow chart, but I'm going to talk about a little bit about the turn option. So how can you turn the robot in words? It's very simple. We should go to this particular one, and we know if we wanted to turn our robo in the right direction, we know that input one should be high, and in two in three in four all should be low. So now you can think about like how we did for the LED bulb. Right? Let's assume that in one has an LED valve. I two has an LED valve. I three and in four, they are all having LED valves. Now you wanted to only turn on the first LED valve. What will you do? Right? So you will try to power up that particular in one only. That means whichever the first LED bulb is connected to, you should power it up. That means you will provide five voltage to that particular bulb. So the same thing will be applied to this particular in one pin, right? It's very simple. No need to confuse about this one. When I'm wiring this one, you will understand this more. Right? So if you come back here, so how can you move the robot in go forward direction. That means if the condition is not true. So it should go in forward direction. So how can you achieve that particular forward motion? It's very simple. You should power up. That means you should provide five voltage to the in one pin and in three pin, and all the rest of the pins should be low. So that is the case that we are going to discuss. But if I wrote the diagram, and if I code it, and then you will understand these things very easily, right? So let's get started to create this particular circuit. Don't worry. Don't confuse. It's very simple. I will tell you how you can step by step, throw this particular wiring diagram. It's very easy, right? So let's get started. And I'm going to name this as four it's project number four, and I wanted to make all the components available for me, I wanted to insert an gino here and bred board and an ultrasonic sensor. I'm going to install this particular four pin sensor and the motors, the DC motors. So here it is. I have to insert two of them, and then after I need to insert a controller. So the controller is a problem here, right? So what I have explained to you in the slides, right? In this particular motor controller, it's called l298 motor controller. But here, we have l293d motor controller. Those are different motor controllers. But the function is same, right? So I will tell you what is the difference in this particular one. You can practice by using this particular motor control, but the coding is same, right? So no need to change the coding, but wiring may be slightly different. I will tell you what is the difference, right? So I'm going to type motor control. So here you have another motor controller, right? It's a Polo motor controller. This is not what we are going to use, and I think I need to type L 293 D. Yeah. So H bridge motor driver. So this is the one I need to insert in here, right? It's like an IC. So what I'm going to do is I'm going to align them all like this, So I'm going to insert this particular one in the middle like this. And it's very simple, no need to confuse anything. So here, if you wanted to wire this particular sensor, it's very simple. You should connect this particular VCC to this positive terminal and the grow to this particular grow. I'm going to change the color. To blue and this one to be red. Now I'm going to connect this trick pin on the eighth pin of the Arduino. Change the color, and the eco pin to this ninth pin on the Arduino and change the color. Now I have finished up the input ir. Now what I have to do I have to connect the output ir It's very simple. What we have to do is we have to power up this particular C. Right? So if you move closer, and here you can notice that it's enable one and enable two pin. It's in one. It's output one, it's grown. It's also grown. It's out two. It's in two, and this is power two. That means in this side, I have some kind of pins, right? So these all pins are responsible for one motor. And this particular side on the abo is responsible for this particular motor. So that is how I'm going to connect it, right? So here, I told you that I need to power up this particular motor controller. So that I need to connect this particular power pin with this positive terminal. I need to connect with this one and should be connected to this pin. So that means I have given the power to this enable one and two, and power pin. That means that this particular one has been connected with this positive terminal. What I'm going to do is I'm going to connect this particular ground. Here we have two grows, and those two gros should be grounded like this. I'm going to change the color blue and blue like this. Now, here we have in one pin and out one pin out two pin and in two pin. Here, you can notice that out one pin and out two pin are responsible for the motor. If you open up this particular motor controller, out one pin and out two pin are responsible for the connection of this particular motor. I'm going to connect the motor with those pins. This particular positive terminal, I'm going to connect it with this particular out one pin. Change the color to red, and this particular pin, I'm going to connect it with the I think this is two. It's out two, so I need to connect it like this, change the color to blue. Now I have connected the motor with this motor controller. Now I have only two pins. Those are responsible for the control of this particular motor. Right? I one and in pin. If you supply in one five voltage and into zero voltage. This particular motor will rotate in forward direction. That means clockwise direction. If you supply five voltage to this particular in two pin and zero voltage to this particular in one pin, and then the motor will rotate in counter clockwise direction. So that is the theory behind it. So that I'm going to connect this particular in one pin with the dino right? I'm going to connect this particular pin to this particular second pin of the albino, like this. I'm going to change the color to maybe a green color because these are signal pins. So I'm going to connect this particular into pin. To the third pin. Change the color slightly a bit, maybe a purple one. Okay, now I have connected this in one pin to the second pin in two pin to the third pin of the window. So now I have finished up the wiring for the left side of the motor, and now I'm going to deal with this particular right side motor, right? It's also similar. Now how I'm going to connect is like this. I'm going to obtain the power from here. And connect it to this one. I'm going to change this to red. I'm just obtaining the power from here and connect it to this particular line. So I can connect straight forward how I have connected like this. So then you can understand the wiring diagram easily. That is why I'm connecting. If you understand the wiring diagram, you can connect however you like it, right? So I'm going to connect this particular line to here, change the color to blue. Right. So now I can connect it straight here, right? So here, this is the power one pin, and I have the enabled three and enable four pins, right? So these pins should be connected to the positive terminal like this and this one. So that's up. Now I have to ground and this, this ground should be grounded like this and like this, change the color blue, and this should also be in blue color. Okay. Now I have four pins available for me to configure. It's very simple. I need to obtain this out three pin. This is the pin, and I need to connect this out three pin with this particular positive terminal and change the color to red and obtain this negative terminal and connect it to this particular four termino. So here, I have only two pins remaining for configuring that one. I need to connect this particular entre pin and info pin to this particular arduino, and here, this particular tri pin should be connected to this dinos fourth pin, right? And I'm going to obtain this particular info that should be connected to this particular binous fifth pin. Change the color to slightly orange. Okay. So that's it. That is how we exactly connect them to the dino and this one, right? So here, now I have to give the power to this particular item. So I I can obtain this particular five voltage from here from the dino and connect it to this pin on the breadboard, change the color to red, obtain the ground from here, and connect it to the dinos ground as well. Change the color to blue, right? So now I have wired up everything else, right? And let's check whether it works or not. How can we check it? We can't check directly. Why? Because we need to program it, whether it works or not. We should program this, so then only it will work. Okay, let's do the programming work, right? I'm going to go to this particular code option and delete the existing code. Expand this a bit, right? So if you wanted to code, you should go back to this particular flow chart. Here, I'm going to quickly go through with this one because this is the fourth time I'm saying this particular same thing. I'm going to quickly control them, read from ultrasonic sensor is here. I need to read from this particular ultrasonic sensor, and they are connected to this eighth spin and ninth pin. I'm going to select eighth spin and ninth pin. I'm going to go with this particular centimeters. Now I need to assign that as a variable called as x And then I have to set that particular reading as x, right? This thing, you know how to do this one. Now, I wanted to check x is less than 30 centimeter. Is it true? I need to check it. For that, I need to go to this control option and drag and rob this particular function in this particular function, I need to insert a math function, and this is the function. It has this particular icon, that means less than or greater than symbol. I need to drag and rob this particular one into this one. Then I have to go to the variables and drag and rob this x here. I'm going to change this to 30. That means if x is less than 30 centimeters and this will happen. You know what should happen. So here, if it is yes, turn right. It should turn in right direction. So how can you make that particular one to turn in right direction? You should come to this particular chart and understand. This is what should happen. It should turn right direction. I one, only high and all this in two in three in four pins should be low. So that I'm going to do that one. So it's in the output section. It's like I told you that. It's like turning on the LD b, right? So I'm going to set this pin and copy this one for four times. Why? Because I have one, two, three, and four pins, right? And then I need to configure the pins. This is one pin. This is two, three, and four. If you notice that, it's d two, d3d4, and D, it's two, three, four and five. If it is like that, this is in one, this is in two, this is in three, and this is in four. Right here in the chart, you can come here, and you can notice that what should happen if it should move in right direction. In one only to be high and all the other things to be low, right? So that I'm going to make this only for high, and the rest of the things should be in low. So all these to be low. So if there is any object present in front of the sensor, that means there is an obstacle in front of the robot, and then the robot will turn in right direction. And then if there is no object in front of the sensor, that means this condition is false, and then this will happen. That means the robot should go in forward direction. For that, I need to duplicate this particular four blocks and paste it down here. Then for the forward movement, I need to set this particular line. In one should be high and in three should be high, and in two and in four should be low. That in two should be high in three. The fourth pin is responsible for the connection of in three. So this one to be high and two should be low. Then if it is not true, that means there is no object in front of the sensor and then the robot will move for this particular condition. So let's try whether this code works or not. This is the coding. Let's try. So now you can notice that it's rotating 140 3:00 P.M. And 140 3:00 P.M. Right? So if I move this one to closer closer and closer, less than this one, now you can notice that in this particular instance, this particular motor is stopped and this particular left motor is still rotating. What's the meaning of that one? Yeah, you guessed it, right? So this is not moving, and this is moving. So then it will have a rightward turning movement, right? So if I take it away and then there is no object to block this one, and then the robo will move in forward direction. And if there is any object present, and then it will turn right direction, and then it will go forward. So that is how we can make a simplified version of obstacle avoiding robo. Right? Okay, so this is a simple task and you can achieve this. It's very simple to make it in the Tinkercad software. You can make this and practice this one. I told you earlier that you should achieve the simplified version of whatever I teach you. And then after you have to expand and complex the project. So if you obtain this particular one, actually, it will not going to work accurately. Why Because the turning movement will not be efficient. That means the right turn will not be efficient. If you practice that one physically, so then you will feel that one. Why? Because you can come over here. Right? So here, in here, this motor is not rotating, and this motor is rotating in forward direction. So then what will happen is the robo will slightly move here, and then it will turn like this. So this is what will happen to this particular robo. That means it will go in for direction, and then it will turn. It's not the actual 90 degree turn, right? You can think about that one, right? So if you wanted to make an accurate 90 degree turn, what you have to do is, it's very simple. You can think about it, right? So if you want to make an accurate right turn, what you should do is, you have to make this particular motor to be rotating in backward direction, and this motor should be rotating in forward direction. So can you think about it, right? So if this is the condition and now you can think about it, this particular robo will suddenly turn in right direction. Why? Because this particular tire or the motor is rotating in backward direction while this particular motor is rotating in forward direction. And then this particular robo will turn accurately. Right? So that is how we can exactly achieve that particular accuracy in this robot system. And let's try that one too. What I'm going to do is I'm going to explain you how we can exactly turn in right direction, right? So here you can notice that. If it is the right turn operation of the robot and the left motor should rotate in forward direction, while the right motor is rotating in backward direction. You know how to rotate that particular right motor in backward direction. You should power up this particular in four pin. It should be high while the three pin is low, so that you can achieve a backward motion of that particular motor. Then for the left motor to rotate in forward direction, you should make this one as high, in one should be high, and two should be low. Right? So same can be applied for this left turn if you want to code the robo for the left turn. And I'm going to stick with this particular right turn. So I'm going to change the code slightly a bit. It's very simple. You can come over here. And for the right turn, in one should be high and info should be high. Here, for the right turning, in one should be high, and info, this is the pin. Fifth pin is connected to this info pin, so that I need to change this to high. In one and info should be high. If it is the condition, now you can test what happens to this one. If I click this here. Now, if there is any object present in front of the sensor. Now you can notice that this motor is rotating in backward direction. That is why we have a negative sign here, and this one is rotating in forward direction. So that means the robot will turn accurately. That is a one tip for achieving the accuracy. Now, what I'm going to do is I'm going to slightly change this one to increase more accuracy. So if you wanted to increase the accuracy, what you have to do is, you have to control the speed of this particular robo. It may be a difficult thing for you, but it's not that much amount of difficult. If you put an effort to understand this one, it will be very easy, right? So now, what I'm going to do is I'm going to control the speed of the two motors. And then when it's turning or when it's moving and the speed will be reduced, and then it will feel accurate turning movement. Right? It's very simple. What you can do is you have connected this particular enable this pin to five voltages, and this particular enabled three. This is enabled pin, it's enabled a pin. So this pin is connected to this particular five voltage, right? So what I'm going to do is I'm going to delete this wire and this one. Now, what I'm going to do is I'm going to connect this particular enable to be connected to the sixth pin and change the color maybe pink. And obtain the enabled three pin and connect it to the ordinose seventh pin. So if I connect like that, I have additionally two pins to configure it. Here, you have a sixth pin and seventh pin. Those two pins should be configured. But here we cannot be able to configure it. Why? Because it's a digital pin. If you wanted to control the speed of that particular motor, you cannot control by using the digital pins. Why? Because the digital pins are responsible for providing only zero or one. For that, what I'm going to do is I'm going to use the PW pins to configure them. Right? So that I'm going to disconnect this particular wire, connect it to this 11th pin, and I'm going to disconnect this particular wire and connect it to this tenth pin, right? So if I do that, what will happen is I have connected with this PWM pins and now I can change the code like this, right? So here, I have to additionally add this particular program over here. I need to insert two times because I have two motors. This particular left side motor is connected with this tenth pin, that the tenth pin, I have to configure this one, and the 11th pin, I need to configure this one. Here, what you have is it has an option to set that particular pin. Here you can change the values in 0-255. If you set that to 255, that means it will rotate its maximum speed. That means it will operate in its maximum speed, it will be given five voltage for all the time, right? So if you set that particular PW and pin maybe to 100 and then it will rotate in the medium speed, right? So I'm going to go with this particular hundred. And now I'm going to copy this one and paste it down here and stay that one asp, because the speed is not going to change if it is moving rightwards or forward. Now I'm going to test this one, whether it works or not. Now you can notice that what has happened to these motors. Previously, the motors were running at a speed of 140 8:00 P.M. And now they are rotating at a speed of 60 RPM. Right? So here, even if I move this particular object near to the sensor, and now you can notice that it's rotating in backward direction while it's rotating in forward direction. So if you are not satisfied with the speed of the motors, what you can do is you can go back to the coding and change the speed, maybe 75 and 75. Because if I wanted to change the speed of this motor, I need to type each and every time all the values, right? For that, I'm going to assign a variable for that particular speed so that I can change the speed whenever I have to change that particular speed, right? So that is the best practice. I need to consider that one. For that, I'm going to go with these variables and create a new variable called as speed or maybe you can change whatever the name you like it and click. Now I need to drag and drop this particular set condition here, and this particular speed variable is initially set 2705. Or maybe 100, whatever you like it. Then initially, the variable speed is set to 100. Now, what I'm going to do is instead of 75 here, I need to drag and drop the variable here. If I do that one, you can notice that the tenth pin will rotate at this particular amount. That particular amount is already configured as 100. That is the best practice in the coding exercise, right? So if I wanted to change the speed, what can I do? I can change this one, maybe 60, and then all the things will be changed as 60. That is why we assign variables, right? So if I start simulation, you can notice that the speed will be further reduced. You can notice that it's rotating about 30 5:00 P.M. Likewise, you can play around with these things, right? You can add an L valve, you can configure a server motor additionally, and you can even you can insert two additional motors to obtain a four wheel robot, and then you can play around with these things, right? So I hope you understand about this one, and that is all about this particular project, right? So if you wanted to achieve this particular project in real time, you have to change your wiring. So the code will not going to change, right? So you have to obtain the code by obtaining block plus text, and then you can copy this particular code here, right? And then this code should be 11. Project 05 - Line Following Robot: Okay. Now we are going to discuss about our fifth project, which is line following robot. Line following robo is simply like this. On the floor, we will draw a line, which will be a black colored line, and then our robot will follow along the line. Why do we have this kind of particular robot? What is the usage of this one? Basically, in factories, We transport material from one place to another. And in those materials can be transferred by these robots, right? So in this project, we are going to make a small prototype which uses two IR sensors to make this particular line following robot. It's very simple and straightforward, I will explain you how we can design the circuit, how we can make the program, and how we can upload it It's very simple. We are going to use L 20098 motor controller and two IR sensors with addition to Avino batteries and the Cortes kit. So it's very simple. I will tell you how you can make this one. So here, as an example, you can see this is an example for line following robot. And it moves along the path that we pre define it on the floor. Here, you can notice that the floor is on white color and the line is in black color. It's important to have the black colored line because the IR sensors will detect that particular black color. Why? Because in those particular R sensor, we have two bulbs. They are not bulbs. The one is a transmitter and one is a receiver, right? So the white color one is a transmitter and the black color one is a receiver. And the white color LD valve will emit a R signal, IR light, and that particular light will be sent to the floor, and then it will reflect it back to the black colored LD valve. So what happens is when it is on the white surface, the reflection will be maximum. So then all the IR rays will be reflected back to the black colored receiver on the R sensor and then the R sensor will provide a signal. That is why the LD valve on the sensor is there. Right? So here in the IR sensor, we have two power LED bubs. So the first one is for the sensors power, and then the second LD bulb is for the signals power, right? If there is any signal, that means if there is any reflection coming back to the sensor, and then the second LD bulb will also be turned on. And if it is on the black surface, what will happen is the black color surface will absorb all the infrared rays. All right. So then there will be no reflections. And then for the receiver, it doesn't receive anything. And then after in the censor, the LED bulb will not be turned on. So that is how it works, and then we have two of them, and the two censors, if they are both detecting something, that means our robo is on the white surface. That means it should move in forward direction. Right? So if one sense are sending the signal and another one didn't, and then we have to go for the turning motions. I will explain it to you later. Let's watch this video completely. This is how it works. If you wanted to end the robot, you should have a T junction like this, then it will be stopped. And this is another example for that one. Okay. And here it will also follow the line that we set on the floor. Okay. Okay, this is the robo that we are going to make. So this is how it works, right? So here, this is a black colored line, and our robo has to follow that particular line. So if you wanted to move the robo in forward direction, what we have to do is the condition should be satisfied. What is the condition? The condition is two sensors detect that particular white surface. All right. So if the left censar doesn't detect anything, that means the left censur is on the black surface, and white sensor is detecting something, and that means the right censor is on the white surface, and then our robot has to turn in left direction. Likewise, you can think about what should happen for the right turn. The right censor doesn't detect anything. That means the right censor is on the black surface and the left censor is on the white surface. Then there should be a right turn has to be done for that particular robo. These are the three motions that we have to consider. And we know where to stop. Right? So this is the condition whether the robo has to stop or it has to move, right? So here, if there is a t junction, and then the both two sensors are not detecting something. That means those two sensors are on the black surface. That means that is the end point of the robo. On there, a robo has to stop. Right. So coming back here and we know that if we wanted to achieve the forward motion, we know what to do with our motors, right? So the one should be high and in three should be high, right? So then our left motor will rotate in clockwise direction, and right motor will also rotate in clockwise direction, and then our robot will move in forward direction. Okay. So likewise, you can consider the left turn. So in one should be low, in two should be low. That means there is no rotation on the left side motor, and we set in three to high and in four to low. That means our right motor will rotate in clockwise direction, and that means our robo will turn in left direction. Likewise, you can think about on the right turn, and in one should be high, in two should be low. That means our left motor will rotate in clockwise direction. And three low and info is also low. That means our right motor is not rotating. That means our robo will turn in right direction. So that is the condition we have to adhere to. But if you wanted to move the robo accurately, you know what to do. In our previous project, I have explained to you how you can turn our robos in right direction or left direction accurately. Right? Okay. So now, we are going to create our flow chart for the project of line following robot. It's very simple, right? It may be confusing for you to see, but it's very simple, right? So here, we have to start it, of course, and read from left sensor. Here we have two sensors present, right? So the left sensor should read something and that particular reading log is monitored and it is assigned as x. Therefore, let the reading be x. And then after we have to read from the right sensor as well, right? So we have to Simultaneously, we have to check both of the sensors, right? So for the right sensor, the reading is y. Let the reading be y. So we have two variables x and y. So we have to check both of the variables, whether they are on the black surface or on the white surface. It's very simple. So if x is equal to one and y is equal to one, what is the meaning of that one? Right? X is equal to one means x is providing signal. That means the left sensor is providing signal and the right sensor is also providing signal. That means all those two sensors are on white surface. So what is the condition that the robot is facing? So basically, that particular condition, our robot has to move forward right? So that is the alignment, right? So it has to move in forward direction. If the condition is false, what will happen? And then there is another chance. So here we have four chances. So if x is equal to zero and y is equal to one, what will happen? Right? So that means the left sensor is on the black surface and the white sensor is on the white surface. So that our robot has to turn in left direction. So then it will be aligned. So if that is also false, so what will happen? And then we have to check the condition of x is equal to one, and y is equal to zero. So in that particular condition, our left sensor is providing signal. And our right censor doesn't. So in that particular se, right, our left sensor is on white surface, right sensor is on black surface. So then our robo has to turn in right direction, so then only, it will be aligned. Even if that is also false, and we have to check the fourth condition, which is the last condition, right? So if x is equal to zero, and y is equal to zero. So what will happen in this particular condition? Both the sensors are not detecting something. That means both the sensors are on black surface, and then we know that that is the stopping point of our robot. Right? So in here, either one of these conditions should be satisfied, right? And then our robot will adhere to that one. So we have four conditions, right? So these are the only four conditions that the robot can have, right? More than that, it cannot. And if you are using two sensors, right? So if you are using three sensors, the condition you will have eight different kinds of options for you. And then you have to compare X, Y, and Z. If you are using three sensors, you have to compare three sensors together. So then you will have eight different chances. I'm not going to explain it to you. If you want, you can do that project as well by using three sensors, right? So here we are going to achieve this particular simplified version of this line following robot. Okay. Now I'm going to make the circuit for you. Before I explain the circuit, I just wanted to show you an important thing. Sensor calibration. This is very important. This is the IR sensor, and this is the power. This is the signal it, and here we have a potential meter for calibration. So if the sensor is powered up, that means the VCC and ground pin are connected to the power source, maybe a battery or Arduino, and this particular power LD will be turned on. That means the sensor is ready to detect something. If this particular signal LD is also turned on, that means this particular surface something. There is something in front of this one to reflect the IR signals back to this receiver. So if we place this particular sensor in front of the black color surface, and then the signal it will be turned off. If it is facing on the white surface, it will be turned on. And also, we have to consider the distance between the sensor and the floor. There should be a very, very minimum amount of distance, maybe within 3 centimeters, maybe 2 centimeters or 1 centimeter. So that will be the range that the sensor can work perfectly, right? Now, you have to obtain a screw driver to adjust this particular potentiometer. How can you calibrate the sensor? It's very simple, if the sensor is facing the white surface, and there should be signal LD turned on. For that, if the LD is not turned on, you have to manually adjust that particular potentiometer by using a screw driver. You have to rotate it until the signal comes on that particular signal LED. That is not the end of the calibration. Again, what you have to do is you have to place your sensor in front of the black colored surface, and then you have to adjust the knob until the signal turns off. And then after you have to recheck that particular two conditions. You have to place it on the white surface, and you should see the signal is turned on. And you have to place the sensor on the black surface. You don't change anything on the potential meter, and the signal LAD should be turned off, right? So if it is satisfied the condition, that means you don't have to calibrate more. That means you don't have to turn the knob anymore. Why? Because the sensor is calibrated perfectly, right? So hope you understand about this one, right? So after you have calibrated the censor, it's very simple. What we have to do is we can do the wiring and we can make the robot. Okay. Now I'm going to do the wiring. So here, I'm going to go to the circuits and click Create New circuit. And here, I'm going to name it as project number five, make all the components available for me. Drag and Rob Urbino, breadboard. Here in this particular software, if I wanted to demonstrate it to you, It's a bit harder for me. Why? Because here we have an R sensor, right? So that particular IR sensor is not this IR sensor. I have explained to you. This is the IR sensor we have to use for our project. That means the line following robot. And here that particular sensor is not in the tinker cat you have this one, this particular sensor. This is not the desired sensor that we are going to use. Why? Because this is for this particular remote. Okay. So I'm not going to insert this one, right? For the demonstration purpose, I wanted to use this particular PIR sensor. I know this is not the sensor that we are going to actually use, but I wanted to demonstrate to you how it is working. Then I can start simulation and make adjust the knob and I can show it to you how the robot will work. So that is for the demonstration purpose. I'm using this sensor, right? So I'm going to have two of them. You can imagine that. This is the left sensor, and this is the right R sensor. Why I choose this one? Because this sensor has three pins, and this sensor is also having three pins, right? So the similar wiring can be done for them. Okay. Now, I wanted to insert DC motor, right? So here, I have to drag and drop it two times like this. So what are the rest of the components that we have? We have to have a motor driver. H bridge motor driver. I'm going to drag and drop this on the middle, and that's it. What I'm going to do is I'm going to wire up this particular two sensors. You know how to wire them up. This is a signal pin, is a power pin, this is a grown pin. The power pin should be connected to this positive, change it to red, and the grown pin should be connected to negative and should be blue. And the signal pin here, I wanted to use this sensor, right? So this is actually an IR sensor. This particular IR sensor can also be used as a digital sensor and analog sensor, right? So here, I'm going to use it as a digital sensor, right? That means if it is white, there'll be a signal. If it is on the black surface, there will be no signal. For those two conditions are there for this particular sensor. Therefore, I wanted to use it as a digital one. I'm going to obtain this particular signal pin and connect it to one of these digital pins. I'm going to go with this eighth pin and change the color to yellow. Similarly, I wanted to wire up the right sensor as well. This is the power pin, should be connected to this positive. This is the negative grounded, right? And here, I wanted to obtain this cable and connect it to the ninth pin, right? Now I have finished up the input wiring. Now, what I wanted to do is I wanted to wire up the output wiring. That means the motors and the motor controllers, et cetera. It's very simple. I wanted to connect this motor controller with the power. That I have to connect this enable a pin. This is enable A, and this is enable B. Enable A should be connected to this one, the power and the power pin is here. So this is also should be connected to this power. And here we have the pin O one and O two pin. Those are for this left side motor, and I'm going to obtain this one and connect it to the this one, obtain this cable and connect it to the out two. This one. It should be black or maybe blue. Similarly, I have to do it for this motor as well, but I didn't finish it one. Here I'm going to finish this one. I have to ground these two things. It's very simple, ground it, ground it. Right? So now, what we have to do is we have two pins in one and two, right? I'm going to connect this particular in one pin, right? So this in one pin should be connected to the second pin of the Arduino, and in two, this pin should be connected to the third pin. Change the color slightly. Okay. Now, I have to connect this with this motor. To do that, what I'm going to do is I'm going to obtain a power from here and connect it to this particular line as well. Here, I wanted to obtain the power from here and connect it to this particular line. I wanted to obtain this line connected to this line. This should be blue. That means this line and this line are connected together, so then I can wire up this motor controller quickly. I need to connect the power. This is the power pin. It should be in a red color one, I need to connect this enable B pin with the power. Then I have to ground it, and these are grounds. I need to ground it like this. And this. So we have four pins. Out three is this one. This is for the connection of the motor positive, right motor positive, O four This one is for the connection of the right motors negative. Then I need to change it to blue. Now we have two pins left in three and in four. I'm going to obtain this particular in three pin and connect it to the fourth pin. Change the color to pink, and this one, info, this is info pin and info pin should be connected to fifth pin. Change the color. Maybe a green color. Okay. Now I have wired up everything. It's very simple. Now I need to provide the power to this particular pin. I need to obtain it from here in the softire but actually it's different. I need to obtain the power from the battery directly and connected to this particular line. If it is the soft tare, you can obtain the power from here on the bino and connect it like this. No worries it will work. But if you are using the actual system, you have to obtain the power and connect it from the battery. Okay. Now I have finished up the wiring. It's very simple and straightforward. No need to worry about those things, and I have the flow chart with me, so then it will be very easy for me to program, right? So I'm going to start with this one, and read from left y sensor. I'm going to go to this code option and delete the existing code. I'm going to expand this a bit. In here, I have to go to this input and it's a digital pin. Then read from digital pin. Which pin I have connected the left R sensor? This left this is a motion sensor, but this left R sensor is connected with the eighth pin. Then I have to select eighth pin, and I need to assign a variable and that is x. You can notice that in this flow chart. Let the reading be x, right? I need to create a variable called the as x and that one has to be set. This x should be the reading of this left R sensor. Similarly, I have to do the same thing for the right sensor as well. These two things should come to this sensor as well. Right? So what I'm going to do is I'm going to create a new variable called as y for the right sensor and click, and I'm going to duplicate this one and paste it below here. I wanted to change the variable to y and y is responsible for the connection of this right sensor, and you know that the right sensor is connected on the ninth pin of the dw. I'm going to go here and change the pin to nine. Okay. Now we have defined two variables, and if I opened the flow chart, and you know that. This is an and function condition. This is an I and function. On that I and function, I have another IL function. If it is no, that means in this function. If it is false, I have another If function. If it is false, I have another one. If it is false, I have another one. That is how it flows. So here, I have to insert a if and function here. It's very simple, drag and drop it here, right? In this particular if and condition, I have to insert this one. X is equal to one and y is equal to one. I have two variables to configure them. For that, I have to go to this math option and drag and drop this one. So this one, I can have only one variable and one configuration, right? For that, I don't want this one directly. I wanted to have two of them, right for x and y, right? I need to set here as x. So for the variables, I need to drag and rob this one, and I need to set this like this. If x is equal to one, right? So I have to select this equal function, and one. And for the right sensor, I need to drag and rob this one and select the equal condition, and I have to check whether it is equal to one or not. But these two conditions, that means the left side reading of the sensor and the right side reading of the sensor. They should be done At the same time. They should be done simultaneously. For that, I have to insert a condition called as this one, condition. That means this condition should come over here and this condition should come over here. Now you can read it, x equal to one y is equal to one. That means all those two conditions should be happening at the same time. If you want, you can change it to but not in this project, if you're doing another project, if it is an condition, that I need to drag and drop the whole thing into this particular function. Now if you read it here, you can understand x is equal to one and y is equal to one. If this is the condition, right? If this condition is true and this will happen. If this particular condition is false, the LS will happen. I'm going to write this one. What will happen if it is true. I need to go back to this one. If it is true, you know what should happen. The robot should go in forward direction. If your robot should go in forward direction, in one should be high, in three should be high, and in two and in four should be low. For that, I need to drag and rob this one four times. Why? Because we are having four terminals in one in two in three, and in four pins. So that we have to have four outwards, and we have to configure them all, right? So here, if you move closer, two, three, four, five, two is for in one, three is for in two, four is four in three, five is four in four p. I need to set them like this. In one should be high, and in three should be high. In one should be high, in three should be high, but this particular in two and in four, they should be low. All right. So now if you read the program, you can understand left sensor is detecting. That means it's on the white surface, right sensor is detecting. That means that is also on the white surface, and then the robo will move in forward direction. If that is not happening, I have to check it again. For that, what I have to do is I have to go back to this flow chart and see if x is equal to zero, and y is equal to one. I have to check this particular condition, whether it's true or not. If it is true, the robot should turn left. If it is four, I need to check the other condition, this one. All right. So I'm going to check this one. It's very simple, right? What I'm going to do is I'm going to simply right click this one and duplicate this one, right? So this is the one I have here, and that one should be pasted down here. And now you can edit it. How can you edit that one, x is equal to which one x is equal to zero, and y is equal to one. X is equal to zero, and y is equal to one. If this is the condition, that means if this condition is satisfied or true, and then the robot should turn in left direction. For that, you have to go here and for the left turn, you know what to do. I three should be high and all the other terminals should be low. Right? So here, in three is with this particular one and all the other terminals, I one, two, in four should be low. This is the condition. What happened? If this is false. You can read the program very well, right? So what happened? If this is false, right? If that condition is not satisfied, it's not true, and then we have to check this condition, right? So, what I'm going to do is I'm going to duplicate that particular one again and paste it down here. So here, what you can do is you have to set this particular condition, x is equal to one, y is equal to zero, x is equal to one, and y is equal to zero. Then what will happen? That means x is on the white surface and y is on the black surface. Then our robo has to turn in right direction. If you wanted to turn our robo in right direction, in one only Should be high and all the other things should be low. For that, what I'm going to do is I'm going to make this in one should be high and all the other things should be low and all the other things should be low. That is the third condition that we have to consider. And the fourth condition. Here, we don't have to write the fourth condition. Why? Because if these three conditions are not satisfied in a line, and then this is the exact condition that will come because that is the rest of the condition we have. For that, I don't need to write anything here. I can just simply duplicate this one and paste it down here, and then I can configure what should happen if this is the condition. And then the robot should stop If this is that means you can notice that here. First of all, I'm checking whether both sensors are on white surface or not. Here, I'm checking whether the right sensor is on the white surface or the left sensor is on the black surface, then it should turn left. Right? Here, the left sensor is on white surface and the right sensor is on black surface, then it should turn right. And if those three conditions are not satisfied one after the another, and then our robot can have only one condition. That particular condition is the stop. The robot should not. Why? Because the robot is feeling a t junction. That means the end If it is, you know what to do. If it is the end, all the things, all the one in two in three and in four, all those pins should be low. That is the program we can write. It's very simple. So let's check whether it works or not. I'm going to click the start simulation Okay. And for the demonstration purpose, I have inserted two sensors, right? So here, the sensor and the sensors all together, those two sensors together are not detecting. That means If this is the case and then actually practically, the robot will be on the block surface. That means these two sensors are on the block surface. That means it's a T junction and then our robot will be stopped. That is why there is no rotations in the motor. If you move this particular sensor and now you can notice that, this one is rotating. Why? Because the sensor is detecting something. That means the sensor is on the white surface, but this is still on the blood surface. Then our robot should turn in left direction. Again, you can click this sensor, and if you move this particular sensor, now you can notice that this particular motor is rotating. Why? Because this sensor is on the white surface, and this is on the black surface, and then our robot has to turn in right direction to align with the particular pre defined line on the floor. Now, I think it's difficult for me. I need to adjust these two sensors together. Right? So if I adjust these two sensors together, right? So then you can notice that both motors should be rotating in forward direction. That means this is also on the white surface. This is also on the white surface. So then our robo will move in forward direction. Hope you understand about this particular line following robot, and this is the simplest way of creating the line following robot, right? It's the simplest way and the simplest program. If you want to achieve the accuracy of the turnings and all the things, you have to work additionally. Right? So what you have to do is you have to set up the speed of the motor, and then you have to configure the turning motions of the motor, right? That means you have to consider the accurate turning moment. That means if you are turning in right direction, the left motor should rotate in forward direction while the right motor is rotating in backward direction, right? So that is the accurate condition turning. You can go over here. Right? So accurate turn right. The left motor should rotate in forward direction while the right motor is rotating in backward direction, right? So then our robo will turn in right direction perfectly. And for the accurate left turn, the right motor should rotate in forward direction while the left motor is rotating in backward direction, right? So that is the condition if you wanted to achieve the accurate turning movement, right? For the turning moments, you can have the chart here. And then you can insert it on the program. What I'm going to do is I'm going to copy this project. This is the simplest way of obtaining that one. I'm going to duplicate this project. In next project, I want to name it as project number five with accuracy. I'm going to make it complex. For that, what I wanted to do is I wanted to delete this enable a pin. I'm going to control the speed of the motors. Delete this enable A and enable B pins, and I'm going to connect this particular enable a pin with the tenth pin of the Arduino. Change the color slightly a bit to brown, the enable B pin for the enable B pin, I wanted to connect it with the 11th pin. Change the color to maybe purple, like this. So now I have configured the enable a pin and enable BP. Now, what I'm going to do is I'm going to change the program for those speeds. Now, what I'm going to do is I'm going to set a variable called speed. Right? And I'm going to set that particular speed. Two. Initially, you know the range is in 0-255. I wanted to set that particular one, 200, so then it will be an optimum speed. It depends on the battery, right? So the speed is depend on the battery, which battery you are using, how many voltages you are supplying for the motors, right? The motor is for six voltages, 12 voltages in between, you can supply the battery. If you supply more than 12 and then the motors will not going to rotate perfectly. So if you are using 12 voltage batteries, and then you may have to configure the speed, right? So because that particular voltage, the speed will be high. Then you have to reduce the speed. And if you are using a six voltage battery, I think you don't have to configure the speed of the motors. Because for the six voltage and the speed will be sufficient and it will be the optimum. Now, I wanted to change the speed to 100 and I have to go to this output terminal, and I have to drag rob this one set pin over here again because we have two motors and to be configured Here I have the tenth pin and the 11th pin connected to N A and enable B. Those pins and the value should be the speed. For that, I need to insert this particular one here and here. So if it is moving in forward direction, and this is the speed. What I'm going to do is I'm going to copy this code and paste it down here. If it is turning in left direction, this is the speed, and I need to duplicate this one again, if it is turning in right direction, and this is the speed. And if it is stopped, no need to configure the speed because it's useless. So here I have configured the speed. I have reduced the speed. If you want, you can check it. Right? So previously it was 148. Now it's around 60. This one is also around 60. Now, what I'm going to do is I'm going to configure this particular accurate turn. If it is an accurate left turn in low in high, in three, high, this is the turn in one, low in two, this is in two, it should be high in three, it should be high in four, should be low. Again, this is for the right turn. If it is an accurate right turn, in one should be high int and in three should be low and infour should be high in one should be high and infour should be high and all these two things should be low, right? So that is the condition for the accurate. Now if I start simulation, now you can check So here, if you notice that if I'm turning this one, that means this sensor is on the white surface, and this is on the block surface. Those are happening simultaneously. And then you can notice that this motor is rotating in forward direction, clockwise, and this one is rotating in backward direction. You can notice that here. So that our robo will turn in left direction accurately. Likewise, for the left side sensor also it will happen. Okay. I'm going to stop the simulation and go to the code. Now, I have to go to this block plus text option, and I need to select all the codes here and copy it. And I'm going to open up this particular arduino SoftaR here I have. I need to create a new sketch. In the new sketch, I have to delete the existing code here and paste the new code for the line following robot. I'm going to save it as project number five on the desktop, save it. So this is the code. Now you have to go to the tools option, select the board, select the processor, and select the port, and then you can upload the code. After you have uploaded the code, you have to wire up everything according to the wiring diagram. Okay, students. And we have finally come to an end of this course, and we have learned a lot of things by discussing the dinos and the programs, how we can create the circuit diagrams, what are the engineering practices and all those things, right? So thank you for attending the course and watching up to the end and thank you very much for enrolling the course. And please provide me five star ratings to grow and let your friends also know about this course and share this course to your friends. Okay, we will meet on our next course. Thank you.