Arduino Programming with XOD #2 - Robot Car

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
today in the workshop we'll be doing more work with Zod we'll learn how to use multiple taxes in our programs and how to create our own custom notes we'll learn about using Zod libraries and then we'll start working on our Zod robot we'll build the robot and learn how to control its led in its motors we're making things move Azad today so welcome to the workshop [Music] hey welcome to the workshop into the second video in our series on programming lozad now I need to let you know that like the first video this video has been sponsored by the folks at Zod now what is Zod well if you didn't see the first video and I strongly advise that you look at that Zod is a graphical programming environment that can be used to develop programs through the arduino without writing any code Zod is a free open source product that can be run in a web browser or can be downloaded and run on a Mac Windows or Linux machine and with Zod you can develop applications very quickly without the tedious e of actually having to write any code now Zod is not going to replace your Arduino IDE you have already been fairly clear about that but I want to reiterate that but however for many applications odd is ideal for getting something quickly developed without having to write a great deal of code now in our first video we looked at the basics of Zod I showed you how to install the Zod IDE onto your computer and then we use Zod to create two different projects the first project was a simple blinking light project very similar to the blink application that we write with the arduino ide the second one was a temperature and humidity sensor with an LCD display that could be switched between Fahrenheit and Celsius and while our second project was certainly more complicated than the first one it still wasn't a very complicated project well I want to start writing more complicated projects with Zod and in order to do that we're going to start working on a Zod project that will continue on through a couple of different videos and this is the project over here this is my Zod robot or at least this is the Zod robot as it looks right now because as we continue it's going to get additional features on it now today I'm going to show you how we put together the basic robot and how we can control the motor and the big LED that I've got on top of the robot like using Zod as future videos go on we'll add more features to our robot and you will see how a complex LOD project can be built now one comment I had about Zod and I got a lot of great comments about Zod in the first video one comment was though that doesn't things tend to get a bit busy when you have a complex program wouldn't it just be very very difficult to read with all those boxes and all those lines except etc so I'm going to address that today and show you how you can write your programs onto multiple patches I'm also going to show you how you can use a pack as a node and how you can add extra libraries to your Zod IDE in order to work with components that are not in the IDE to begin with so there's a lot to cover today so let's get started by taking a quick look at our sorrow bot project so here's our little Zog robot as you can see it's a fairly simple design it's on a standard robot base that you can buy pretty well anywhere it's got two wheels and a caster on it there's also a little power switch on here and that's to switch the supply voltage to the motor on and off now speaking of supply voltage I've used for double-a cells to provide 6 volts over here and this is going to be for powering the motor as well as for an additional servo motor that isn't on the robot at the moment that's for a future iteration of the design over here I've got a USB power bank I've got another one just like it over here to show you these devices are great they contain a rechargeable battery and what you do is you take a micro USB cable and plug it into here from a standard USB charger that charge this device up and then after that you can start powering devices off of it by using this Jack over here so I've got a small cable here I'm going to plug it into there and want to power up this Arduino mega that got on the top of the robot over here Omega is going to be used for their robots intelligence now you could use an Arduino Uno it will fit on to the same mounts over here and for today's video I'm not using any pins that are mega specific so you can use a new no but I wanted to use a mega because we're going to be expanding this robot we're also going to be making use of the extra i/o pins on the mega and perhaps even some of the extra memory that megha has so that's why I started with that now on the front we've got an ell 298 and motor controller we've seen that before it's an eighth bridge and that's just driving the two DC motors on the top I've got a Power Distribution board that I wired up and this basically is this taking the six volts from the battery and the five volts in the arid we know it's sending it down to this board it's also bringing it out on two pins over here so that I can do future experimenting and I've also got some connectors I've wired here I don't know if you can see that these are for the servo motor I was talking about I wanted the power the servo motor off of the six volt power supply and not off the arduino 5 volt supply because I don't like powering servos from their dwee no power supply and so that's why I've elected to use 6 volts and not 7.5 like I have in some other designs so as you can see it's a very basic robot design and we'll be expanding upon this in this video and in future videos and we're going to be making this robot run and work with Zod so here are the components for our Zod robot project they've laid them out in the workbench because I think it's going to be a bit easier while we're experimenting if they actually aren't on the robot base and running around the room every time we make a coding change so here's the components as follows I'm using an Arduino Uno for these experiments because as I said before although I'm using an Arduino mega on the robot I'm not using any pins or features on Omega that aren't also present on the uno so you can use either one and it'll work just fine now here are my two motors have got little encoder discs on the motor so you can observe they're rotating a little easier this is the L 298 and H bridge motor controller here of course is the six volts I've got in the form of four double-a cells here's my RGB LED this is a big LED I had left over from the video I did on our DB LEDs it's a 10 millimeter LED and it takes more current than many our DB LEDs and so that's reflected in the value of the dropping resistors that you can also see here on this board here and so we're going to be using this setup in order to test out our Zod code so now let's take a look at how it's all wired up so here's the wiring for our Zog robot now we will need either an Arduino mega or an Arduino Uno I'm showing an enol on this diagram but the wiring is identical for both you'll also need an ell 298 and motor controller two DC motors an RGB LED I'm using a 10 millimeter RGB LED but you can use a standard five millimeter one if you wish dropping resistors for the LED now I'm using a different value for my red segment as I am for the green and the blue segment and again because I've got the 10 millimeter led the dropping resistor values I'm using may not be the ones correct for your LED I'm passing 20 milliamps through each segment of the LED and so I'm using a 150 ohm dropping resistor for the red and 75 ohm dropping resistors for the blue and the green you'll also need a power supply for the motor I'm using a 6 volt supply consisting of four double A batteries now here's how we'll wire the components we'll take the ground from the Arduino and connect it to the ground on the L 298 and motor controller we'll take the 5 volts in the Arduino and we'll connect it to the 5 volt connection on the L 2 98n we'll also make sure we remove the jumper on the L 298 and controller so that we can run from an external 5 volt supply we'll take the 6 volt power supply connect its ground to the ground than the L 2 98n and connect the positive 6 volts to the input for the positive motor supply on the L 2 98n the enable a can on the L 2 98n will connect the pin 3 on the Arduino input 1 will connect the pin 2 input 2 will connect to pin 4 the enable beeline on the L 298 and we'll connect the pin 6 on the Arduino input 3 will connect to pin 7 and input 4 to pin 8 now for the LED wiring we'll connect the red segment of the LED through a 150 ohm dropping resistor to pin 9 of the Arduino we'll connect the green segment of the LED through a 75 ohm dropping resistor to pin 10 of the Arduino and the blue section of the LED will go through its 75 ohm dropping resistor and connect the pin 11 of the Arduino connect the common lead of the RGB LED to the Arduino ground and finally connect the two motors to the l2 98n motor controller and this completes the wiring of our robot so now that you've seen how all the parts for our robot are hooked up it's time to begin programming with Zod now the first element we're going to program for is the RGB LED now as you recall an RGB LED is this - red green blue LED in the same package and we can use it to create a multitude of different colors if you're unfamiliar with RGB LEDs I just did a video on RGB LEDs so you might want to check that out now in order to program the RGB LED with Zod we're going to need an RGB LED node and when we look in zog we'll find there is no RGB LED node well we could use three separate LED nodes and that would work just fine but I want to show you a technique in which we can create our own custom nodes with Zod so let's take a look at that right now so let's use Zod to control the RGB LED and the two motors that we have on the workbench now I've opened up my Zod IDE and I've started a new program so I've got one patch which is called main and I want to control the RGB LED to start with now I can go into my common hardware here and look for an RGB LED but I'll tell you right now I'm not going to be very successful finding one by the way in order to find a node a much quicker technique than scrolling through the library is to double click on an area on your pack this will open up a search nodes box and from here you can just type in the name of the node you're looking for now I'm looking for an RGB LED so let's type in RGB and I get a couple of results and as I highlight them I'll see what the actual node is none of these seem to be the RGB LED I'm looking for let's look for an LED and again we get a couple of nodes including the common Hardware one the LED that we're used to using now if I want to use the LED or anything that I find in a search I just need to click on it and then it'll appear right here in my patch now I could use three LEDs to control my RGB LED because after all and RGB LED is just a red green and blue LED in the same package but I think it would be a lot more convenient if I had just one node that could control the entire RDB LED so what I can do is I can actually make my own node so let's get rid of this led by highlighting it and hitting delete then we'll go into file and we'll make a new patch you can also do this with ctrl n you'll get a dialog box that asks you for the name of the new patch I'm going to call mine RGB LED and it's conventional to do this in lowercase by the way and I'll hit confirm so now we've got another patch called RGB LED so let's open our search again and we'll look for an LED and here's our LED so let's put one on to here now we've highlighted the LED let's do ctrl C to copy and ctrl V to paste there's a second LED let's do another control V now we've got three LEDs which is what we want let's just bring them down over here so we can work on them now let's go into the description for each LED and just change it a bit so we know what they are this is my red my green and my blue so my red green and blue LEDs now what I want to do is I want to create a node using this pack and in order to do this I need to be able to create input and output pins like any node has and if you go into this library here called Zod patchnotes you'll see a number of things you can use a number of inputs and a number of outputs now let's take a look at one of our LEDs I've got one highlighted here and it's got two inputs a port and the luminance the L um now these are both of type number you need to know this so we're looking for an input number so this is an input number let's bring one up over here in fact let's bring a bunch of them up because we've got three LEDs and Levy's got two input so we need six of these so I'm going to ctrl C and then control via number of times okay so now I've got six of these let's just move them around so they're a little easier to see okay what I'm going to do now is make a link between these and between the actual pins on my notes okay now I'm going to go on to each of these input numbers and just give it a bit of information like specifically a name now this is going to the port on my red LED so I'm just gonna call this or port that's all I really need to do here and I'll do the same for the rest of these okay so I've given a name to all of these different inputs and that should about do it for my RGB LED at least for right now now let's go back into my main patch first of all I'm gonna save my program which is not a bad thing to do I'll call it just calling it RGB control you can call it anything you like now if I look under my project I'll see I have RGB LED and if I look in here and drag it I actually have a node called RGB LED and you'll notice that my node has like an hour port and our Lum deep or key Lum and a B port and below this is I defined it you'll notice I have no descriptions for any of these ports I can actually add them if I wanted to but go back into my RGB LED and let's go to the first one for example I'll give a description to this now let's go back into here and as you soups I didn't mean to do that let's go back into here and as you can see I've now got a description which I've written myself so you can create descriptions for everything including the RGB LED itself so you can create a node that's just as useful and versatile as a built-in node so let's see if I know it works so I need to add the port number so the red is going to nine ten nine of my Arduino G is going to pin 10 and B is going to pin 11 okay let's go some luminance values to thing let's give a value of 1 to red now remember these values go between 0 & 1 and because I've got the LED connected two ports that support PWM I can vary the intensity of their red green in the blue so I'm just going to set red to one right now save my project and upload it to my Arduino okay and as you can hopefully see I've got a light that's lit up it's a little hard to see the color of this right now no bending it doesn't do anything but trust me that's willing red right now go back into here if we wish and we'll set the blue on so now set the luminance luminance of the blue to 1 let's just deploy that and it is now deployed in blue so as you can see I can control the RGB LED with a node that it created myself out of another patch so now that we've seen how we can control an RGB LED with Zod it's time to move on to controlling our DC motor using the el 298 and H bridge controller now this is another case in which you're not going to find a node already pre-made for the H bridge controller in your Zod IDE now unlike with the RGB LED where we created our own node we're going to solve this problem by adding a new library to our Azad IDE and I'm going to show you how to do that because just like the Arduino you can add new libraries into your Zod IDE when you're dealing with a component that wasn't part of the original IDE so let's take a look at how we add a library to Zod and how we use it to control the l-29 t8 and motor controller so now that we've seen how to use Zod to control our RGB LED let's move on and control our two motors now of course our motors are being controlled with the l-29 t8 in dual each bridge motor controller so that's the type of a node that we need to add to our pact so I'm back in the main pack I want to add a controller for that so I'm going to double click insert nodes held 298 N and there's one that is called H bridge DC motor controller and it looks like it might be promising except for one thing when I'm looking at the pins on it I've got a speed pin for setting the speed of the motor and that's fine a pwm pin to go to the PWM controller line which is called the enable line on my L 298 and that's fine too and then a pin for direction but actually on the L 298 n I've got two pins for direction naught 1 1 is the inverse of the other and so this isn't going to work properly for me so I've got two choices I could actually build my own H bridge DC motor controller using this one as a prototype and just adding an inverter into it and that would work fine but there's another way of doing it and I want to tell you that now most of the hardware that we worked with before has come from the Zod common hardware library that we've seen down here now this Hardware of course is hardware that we created this is a node we've created to represent an RD be led but when you need a node for some hardware and it isn't in your Zod common hardware there's a possibility that someone else has created it and placed it in another library the Zod IDE like the Arduino IDE can have other libraries added to it so when you need to add piece of hardware that isn't built into your IDE you can simply install the library containing that piece of hardware so let's look through one for our motor controller and here's one that will actually work perfectly now I looked in the sod libraries which is part of the sod website and you can go that to the sod website at XO d IL and then go into the library section and you'll see a number of different libraries the one that I found was this one it's an H bridge with - dir pins on it basically it's the exact same thing we looked at before except they've got two pins your dir and that's going to be perfect so the way I install this library is I take a look at the actual part number in the beginning of the part number is always the name of the library so I'm going to copy that go back here under file I'm gonna add a library I'm gonna ask me for the name of the library so I'm going to look for this and this is it over here so now another library is being added to my zod IDE if I look in that library I'll see I have one node which is the H bridge I'm looking for now let's bring that out now one thing you'll notice about this H bridge node is this is just a single H bridge where the L - 98 n is actually a dual h bridge so let's make a copy of this node ctrl-c and ctrl-v and we'll this label them motor a and motor B now let's take a look at these pins the Tudor pins are the enable one and enable two lines i've got connected the pins for and pin two the pwm input is the enable line and I've got that connected to pin three remember this is the one that supports PWM let's set up motor B okay so the key to controlling our motors is on the speed pin now if you look over here it'll tell you it's a number and it can go from negative one to one now a speed of one is full speed ahead forward a speed of negative one is full speed in Reverse and a speed of zero is to stop the motor and any number in between will give you a gradual speed between zero and one of the motor so let's just set this to zero point six and this is motor a and motor B let's just set this to negative zero point six so each motor should spend about 60% of its speed but motor B should spin backwards for motor a let's just save our project and deploy it so my two motors are spinning and they're spinning in opposite directions because I told motor a to spin forward and motor B to spin backwards and they're going at about 60% speed right now and so there you have it as you can see it's pretty easy to control our motors using azad so now that you've seen how to control both the LED and the motors on the workbench it's time to move everything over to the apps will robot chassis itself before we do though there's one thing I want to mention the nodes we've looked at so far are very good at controlling the devices that we're using but they don't work well in what I would call sequential programming because something we're going to need for our robot what I meet by sequential programming is when the robot gets an instruction such as move ahead for 2 seconds and then another instruction move left then another one move right turn the light on turn the light off that sort of thing what works very well and odd for sequential programming are nodes that are set up with an input called a set and an output called a done now these work with pulses and as you recall from our first zog lessons pulses are very important inside we used a square wave generator for example to flash a light on and off we use pulse inputs when we developed our digital thermometer and humidity indicator in order to refresh the display so pulses are a very important concept in zod so what we need to do is convert the nodes that we just built into sequential notes notes that we can turn on tell them what we want to do and how long we want to do it for and then when they're finished they will send a done pulse out to the next node which in turn follows its particular instructions so let's go ahead and take the nodes that we've already worked on and convert them into sequential nodes so I'm going to build a couple of sequential nodes they'll be able to use these nodes to control the operation of my robot so we want to need nodes for both the RGB LED and for the h-bridge motor drivers so let's start by building one for the RGB LED now I've got a new project builder here so it's got nothing in the main got another patch and that patch is the RGB LED that we built earlier now there's one thing I've done to this patch just to enhance it a bit and I want to show you that right now if you take a look in the description of the patch I've actually got a full-fledged description over here and I essentially stole that from the description of an LED that I took here and then this modified it a little bit so that I could say RGB LED and I did the same thing for all the input pins as well so for example for the are port pin I've got a complete description over here and if you go down to the LED of this taking a description from that and basically said red LEDs though I thought I had it and I did that the same for the G port and the B port for example they also did that for the other pin for the our alum pin over here I took the luminance description and added it to that and what that's going to do is that when I go to a project let's say I went into my main and added one of my RGB LEDs into the picture now if you look at the help screen I've got a complete set of help descriptions for every one of the pins and fritti RGB LED itself so it looks like a proper note exactly like a node that's already built into the common hardware collection over here so this is a very good technique and it's a very good thing to do when you're programming that way when you build some of these custom nodes you'll know what all of these pins actually do so let's delete that right now because I'm not going to use that here instead what I'm going to do is create a new node which you can do with ctrl N or you can go up the file and do new patch and I'm going to call my patch event RGB LED display and the reason I called it that was that this is an event this is an event I want to happen and so I'm gonna call all of my sequential nodes prefixed with the word event and so an event and then what it is I want to happen during the event so in this particular one I want to display something on the RGB LED so the first thing I want to add to this patch is an RGB LED all right so I'll take my RGB LED and we're familiar with it I'm not going to do anything to the RGB LED itself remember I'm trying to make a note that I can use in a sequence and so my notes going to need a set input and it's going to need a done output and those are both pulse inputs and outputs so I may as well add those right now so if you remember we go to Zod - course I can do an input pulse I'll place it over here I'm going to call this set and I'm going to look for an output pulse I'll place it somewhere down here I guess and label it done now what I want to do is I want to be able to go into this and to illuminate my RGB LED to the RGB values of my choosing for a specific amount of time and I want to be able to choose a time so what I'm going to do is I'm going to add a delay node and that's going to cover a lot of the logic for me so I double click here to search for nodes and they look for the delay node and it's a core zod node so let's put that here let's just move this up a little bit now if you look at the delayed node it already has a set input on it and it has a done pulse output so it's actually very good for creating these little notes and what the delay node will do is it's got this pin called T and that's the amount of time specified in seconds the delay will occur during the delay this pin that says AC t will go true so this will be true during the delay period and then it'll go false afterwards and once the delay is finished it'll send out a done pulse it is started by sending in a set pulse and you can reset it in the middle of a delay but giving it a reset pulse which we're not going to use so let's connect my set to the set on this delay I'm also going to get myself another input know this will be an input number and I happen to know I'm going to need quite a few of those input numbers in fact I believe I need six more so I do the ctrl C No okay I don't know I may have grabbed a few too many over there but we can always delete them later let's just move them out of the way okay this one I'm going to use I'm gonna go to the T and this is the time input and so I'm going to call it t and we'll go down into my delay get the description here copy that and then go back into here and paste that description in okay now the next thing I'm going to do is you see I've got a done output over here now you might think I'm going to connect that directly to the done output of the delay but I'm not going to do that I'm going to use another node first and I'll explain why let's look for defer I'm gonna take a defer pulse now defers a node that we're going to be making a lot of use of in the next couple of demonstrations what deferred does is it waits until the odd is finished doing all of its processing before it makes the next move and it can be very useful in creating loops and doing timing things like in this case we're going to send and dot a done pulse out but it's possible that the other logic we're going to put in here might still be doing something and so defer will make everything wait until it's truly done before it sends a pulse out so I'm just going to connect done to here and I'm gonna get this to the done output so now here's my gun output with a defer on it okay now I'm gonna need a couple of other basic nodes over here but before I do add them I'm going to add a few more connections now the first one I'm going to add is to the airport I'm gonna skip on here add this to the G port skip another one and add that to the B port and I do have the right number place okay so let's label these nodes now this is the our port so we call it bar and once again I'm going to go into the actual device itself and just copy the description here and place it into description for the our port I'm going to do the same thing for this which is V port and then for the last one which would be B port and the description will gain basically the same except it's going to be so I'm not going to connect the luminance pins directly up to these input ports and the reason for that is that I want to be able to turn the LED off if I connect them directly and give them values here then there's going to be nothing to say switch everything off to zero so in order to do that I'm going to add another node do you remember our if-else node let's add three of those actually we work with if-else before let's make three o'clock two copies of it control C and control V control V to do the trick and move one of them about here the other one will move about here I guess we'll stretch you back a little more and move you a bit more and you can move over here okay now if you remember an if-else has a true and a false input over here and we set a value on these a number value and this is the condition input and this is the output of the nfl's and so when the condition is true whatever numeric value is sitting here in the true will be passed out to here if the condition is false whatever value sits at false will be passed out to here so I'm going to connect our outputs down to the lumens and then connect the true values to our inputs because this is the value I want to pass down and again I'm going to label my inputs be our alum and I'll take the description of our alum I'll do the same for this okay now let's just drag a little bit of this stuff down so we can move these down a bit okay very good now all that remains to be done is to take these conditioned inputs and hook them up to the act output of the delay and so I'm going to do that all three of them all right and I'm going to save my frog yet so again what's going to happen is we're going to set a delay over here the delay is going to be specified by the T during the delay period this condition will go true and while it's true it will pass the value here down to the luminance port and this will cause the LED to glow and whatever color were specifying on these three pins over here when everything is finished this apt line will go false and we'll get a zero which if you look at the if-else over here is zero is what's sitting on the false side and zero will turn the LEDs off while all of that's taking place to defer to will be patiently waiting and once it's done it'll send the done pulse out so this is how this particular node is going to work so let's test out the new sequential node that we just made let's drag it on to our main pack and you'll notice it's got all of its descriptions and everything because we wrote that in when we created it you'll also notice that it has a t a set and a done input and output respectively and that's what makes it different from our RGB display node that we created earlier now let's fill in a few of the values that we know over here so we know our port that's nine you know our D port is 10 and the B port we know to be 11 okay now we want this light to turn on for a period of time now this is specified in seconds I'm going to say 4 seconds here and of course right now it's outputting 0 so - I'll put nothing let's give it a color let's just turn on the red one right now I'll set that to 1 okay so now when this note is activated it could turn the red segment of the RGB display on for 4 seconds and then turn it off now this is not going to be activated - sitting here by itself it needs a pulse into the set so a good pulse to give it is a bhoot pulse will look for boot and here we have boot now what the boot node does is it outputs a pulse when the program starts and that's pretty well what we need so let's connect the output of that to our set and to save our program control s and deploy it to our Arduino which is the Arduino mega sitting on top of our robot car and we'll see what happens and there we go the lights on and then it turns itself off after four seconds so that works very nicely let's do something with this let's just take this and do a ctrl C to copy it gonna make a couple copies of this put them one on top of each other let's go back to our first one and just label it we had this one going the red slips let's call it red red display now let's go into this one since it's an exact copy it's already got our pin numbers and time delays in it let's change the color let's set red to zero now let's set the blue to one let's call this blue display oops now we'll go into the last one make that a one and call you okay so I've got it set to four seconds for each of these red green and blue so let's take the done output of red connected to the set input on blue the done output here and connect it to the set input on green we'll save that and now we'll upload to Arduino as you can see we just went through our sequence so that's great except of course once we came to the end here nothing happens so be nice to go in a loop but we can't just take the done and connect it over to the set over here it won't allow us to do that you can have only one link going to an input so what we need to do is bring our good friend deferring defer pulse now what the FIR pulse is going to do is it's going to wait till everything finished and then it's going to go up and set again the connect to the input and not the output now if I take the output here though of course I've got the same problem I can't connect it there's a solution to that there's another node called any basically any will output a pulse when any of its impulses in ports are given a pulse so let's connect any up like this and connect that to the set so now what will happen is we'll have a bhoot pulse that will go through any and it'll pass through and it'll set this will go through our red blue and green displays after that dun goes through defer waits till everything is stopped and sends another pulse up to any which will pass it through the set and it should go over and over again in a loop so let's save that and now it's deployed so there's a red blue green then it goes back to red again because the loop is running so this works successfully so now we've successfully built some sequential nodes that we can use in our robotics programming let's now go and do the same thing for the motors so creating sequential nodes for the motors is pretty well the same as creating them for the LED displays first of all we're going to go and create a new pack I'm going to call this one event motor move because we want to make a sequence of moving the motors and so here we are in our package now of course we're going to need some eight bridges remember that the L - 98 and is active dual h bridge so we need to these modules so let's take one and then ctrl-c and ctrl-v should give us a second one okay and let's just label them loader a motor beam you could do left and right if that's your preference now just like we did for our last sequential node we're going to use a delay node so we'll add our delay node in over here bring the motors down a bit because I have a feeling we'll have some other stuff up here now let's do an input pulse let's call it set and link it to the set pin okay and we might as well get our defer defer a pulse and we'll take an output pulse call it done spelled done correctly and do that okay now if you think about it our eight bridges have four inputs three of them are the inputs to the dirt and the not Derwent to the the in-1 and in2 pins on the l-29 t8n and then the pwm which is the enable pin and then we've got a speed input and this is the value from zero to one that we want it to go or from negative one to zero if we wanted to go backwards and so three of these pins can actually be passed directly outside of our node right now so let's get an input number we know we're going to need one for the T here call this T and we'll take the description for key right here take another input number node I'm going to need quite a few of them we're going to need eight in total so I'll need to copy this seven times ctrl C that should hopefully be enough for them move them around a bit okay several of these we can connect directly and the other one will make use of the if Alice's look we did before all right control V because we need two of them so if else is going to take the speed value that we're going to connect in over here to its troop in so whatever the condition here is true it'll pass the speed value down to the motor if it's false it'll pass a zero to the motor which will effectively turn off the motor so let's make our last couple of connections here okay and all we want to do is some labeling now and we look like we have one we're not using here let's just remove that ok let's save our project and now we can go back in the main and make use of our event motor move nodes that we just created so let's add our new event motor move on to our main so we can watch it work let's pull one out over here for a second now to save time I didn't add a number of the descriptions over here but in the copy that I have for you to download from the drum workshop comm website I'll have all the descriptions in there a game like our display nodes this has a set a done and a tea on it along with the regular connections in this case 4 to 8 bridges so let's go and define those each bridge connections right now I'll just get mine out over here Sodor a on mine is pin 4 inverted dirt a is pin 2 and the PWM on a is pin 3 I'll go down here this is pin 8 which is the same as my in3 there's been 7 this has been 6 ok now we'll set a time we want our motors to run let's look at run for 2 seconds and now we have to set the speed values of the motors now remember this goes from negative 1 to positive 1 where negative 1 is full-speed reverse and positive 1 is full speed ahead and 0 is stop and any number in between is a smaller speed so let's set this guy up 0.8 that's almost full speed what does that look like the same speed so set both motors to the same speed for 2 seconds so let's just give this a name again call this move forward because that's what it's going to do so let's make a copy that and we'll go onto this one let's call this one move backwards or move reverse we'll go to our speed values and we'll make them negative numbers and why not make one more coffee call this move turn a mu spin actual is better I'm gonna set this to 0.5 I'll set this one to negative 0.5 so the motors will move in the opposite direction so that's a spin all right so let's add this into my little program let's break a few of these links here move these things down a little bit more ok we'll slip a motor forward in here motor reverse at the very end and motor spin ol motor spin - I think I want it to spin for about a second so let's change time on that and so now let's just like all of these together okay this link is bad here it's good instead go to here and is done in this set here and let's save that I've got my car ready to load this up - I'm just gonna hold the car because after I deploy it to the Arduino the motors are gonna start moving I don't want to move all over the desk okay red motors move forward blue our motors move opposite directions for a second and then green and the motor reverses then it goes red and it will start to sequence over again so there we have a sequence there's odd robot so after putting together a robot car of course I want to give it a little demonstration so I'm about to put it down on the floor and run it around so you can see it go back and forth now one thing I noticed about my robot car is it has a little bit of a wheel alignment problem so to speak I'm not sure if it's that one motor is turning slightly faster than the other motor or if one motor doesn't have the torque the other one doesn't or if it's an issue with one of them slipping on the wheels but it does seem to pull to one side more than the other so as a disclaimer I went into the code and kind of adjusted it the street and the motors out a bit but it still does pull to one side nonetheless here it is the zod robot car demo number one [Music] [Applause] [Music] [Applause] [Music] [Applause] [Music] alright that about wraps it up for today's video now of course today what we've done is we've built this Zod robot base and we've learned how to control both the motor and the LED we've also used a couple of new programming techniques within Zod now in the next video in this series we're going to add some additional components to the robot base you might recall that I said I'd wired up for a servo motor well that's one of the components we're going to be adding in order to give our robot a bit more functionality so please stay tuned for that now the best way to find out about new videos is to subscribe to the YouTube channel so if you haven't done that already please do I'd really appreciate that and it'll let you know whenever I make new videos another great way of staying in touch is to join the drone bot workshop newsletter and you'll find a link to the newsletter in the description below the video the newsletter is my way of communicating with you and finding out what I'm doing right and what I'm not doing right finding out what videos you would like me to make for you so please consider joining the newsletter so that I can get some feedback from you and help make these videos and articles even more useful for you now as always there is an article on the drone bot workshop calm website that goes along with this video so please cap that out the link is also in the description below until the next time please take care of yourselves and I hope to see you again really soon in the workshop bye for now [Music]
Info
Channel: DroneBot Workshop
Views: 64,464
Rating: undefined out of 5
Keywords: XOD, Arduino, XOD Robot, Robotics, Robot Car, XOD Arduino Project, XOD Libraries, XOD nodes, Arduino Programming, Programming Tutorial, XOD Tutorial, L298N H-Bridge, RGB LED
Id: vuYet9v67oo
Channel Id: undefined
Length: 56min 46sec (3406 seconds)
Published: Tue May 01 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.