RC Robot Car - RC Controls and Arduino

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
today in the workshop we're working with rc remote controls we'll see how these controls work and how we can use them with and without an arduino we'll also build a remote controlled robot car i'm sure you'll find it more than remotely fascinating so welcome to the workshop [Music] well hello and welcome to the workshop and today we are going to be working with remote controls now we've worked with remote controls before of course and several varieties of them we've built circuits that use bluetooth for remote we've used wi-fi for remote and we've also used little rf modules like the nrf24l01 to make remote controlled devices and send data wirelessly however today we're going to do it a different way and what i'm going to be using is this now this is a remote control that you're probably familiar with when you think about things like model airplanes model helicopters model boats or rovers but these types of controls can also be used for your projects very easily in fact in some situations you might be able to use them without a microcontroller because they're very powerful devices now the device i have over here which is a fly sky fs i6x control is a very very common remote control device and you can buy this complete with a receiver for under 50 us dollars at amazon or a number of other places and for what you get for that money it's actually an incredible little device and so if you want to build a remote that can control things over a great distance that has a great number of controls and displays etc on it using something like this is really a good idea so let's start off as we always do by learning a little bit about what we're doing so let's learn how remote controls work rc remote controls are used for model aviation watercraft and ground vehicles these controls are also useful for any remote control project this setup consists of both a transmitter and a matching receiver in order for everything to work the transmitter and receiver need to be bound to one another generally when you buy an rc remote control your receiver and transmitter will already be pre-bound most rc remote controls operate on frequencies that don't require licensing the actual frequency will be dependent upon your local regulations older rc remotes operated in the megahertz band with 27 49 72 and 75 megahertz being common frequencies newer devices tend to use the 2.4 gigahertz band the older megahertz units required that you selected a unique channel to avoid interference with other rc remotes 2.4 gigahertz units don't have that requirement as they use a spread spectrum technique to select an available channel on their own one thing you should be aware of with the 2.4 gigahertz units however is they require line of sight operation so you need to have nothing blocking you from the remote device that you're trying to control rc remotes operate on the principle of a number of control channels the unit i'm using has six control channels but a firmware update can update this to 10 channels on the transmitter each one of the channels is mapped to one of the controls you'll notice that the two sticks actually have two channels associated with them one for the horizontal movement and another one for the vertical on the receiver end each of the channels is mapped to one of the three pin outputs these three pin outputs are generally pulse width modulation or pulse position modulation many devices also have serial inputs and outputs the protocol used on the serial inputs and outputs depends upon the brand of transmitter and receiver the fly sky unit that i'm using uses the ibus protocol on its serial ports one specification that you'll find for rc remote controls is the mode that they operate in this is generally used for avionics but you should be aware of what it is mode 1 is the oldest mode and the controls are mapped as follows mode 2 is these days the most common mode that you will find so most new transmitters will use this mode mode 3 is actually the reverse of mode 2 and mode 4 is the reverse of mode 1. these reverse modes are useful for those who are left-handed if you're using your rc remote for non-aviation purposes these modes really don't make a lot of differences most rc controllers will allow rearrangement of the controls in order to accommodate the different modes you can also change the channel assignments for the different controls and this can be very useful especially in the case of a remote that i have that has 10 controls but by default only six channels the pwm outputs on the receivers can drive servo motors and electronic speed controls directly without any microcontroller involved these outputs as well as a serial output can also be used as an input for a microcontroller to add additional functionality you should note that most of these receivers use a 5 volt output level so you'll need to do some logic level conversions for newer microcontrollers today we're just going to focus on the older arduino avr controllers that require five volt ttl levels so with all that said let's take a look at the remote control that we'll be using today now this is the controller we're going to be using it's the fly sky fx i6x controller it's an extremely inexpensive controller so you can get this for about 40 45 us dollars complete with almost everything you see here i've got an extra receiver module which i'll explain in a moment but basically the controller is pretty simple to use and it's typical of a lot of rc controllers it has one stick over here and this one automatically centers so when you let go of it it automatically goes to the middle of it this stick over here also moves in both directions it will center this way but this way you can put it into any position that you wish each one of these sticks also has little controls on the side over here and these are used for trimming it for fine-tuning it so to speak you can see there's a number of buttons on the front over here and an lcd display there's a button over here that is used for binding the receiver to the transmitter there are a couple of potentiometers up over here two pots that you can use as part of your control system it also has a series of switches on the top over here and this particular switch here is a two position switch now on the back of this controller you'll notice a little din plug over here and the controller comes with this cable at least mined it i understood that some people didn't get a cable with theirs but this allows you to connect the usb to it and you can use the usb for a couple of things you can use it to do a firmware update you can also use it when you're using this with flight controller software where you're doing flight simulations and you can use your controller so to practice flying without a real quadcopter or plane that is kind of ideal now it comes with a receiver and this is the receiver over here the fsi a6b and it's a six-channel receiver you can see it's got a couple of antennas on it over here it's got outputs on it and if we take a look at it closely you will see it's got a series of outputs down over here and these are the outputs for the various channels and the two at the top over here are for the ibus and the ibus is a serial connection that you can make and it's a more advanced way of connecting things there's also a little update switch here and an led to let you know when it's on and a couple of antennas now it also comes with this and what this is for is for binding the receiver to the transmitter now the one that comes with your transmitter is already bound to it but if you need to bind the new one the end connection over here this is the connection that you would normally use for your battery and the bottom would be the ground in the middle would be the positive the top is usually a signal wire but on the end one if you connect ground to that signal wire you can actually bind this transmitter and they give you this little jumper to facilitate doing that so you can just place that in over here and bind the transmitter you can also use the little pin on this over here to do an update over here if you need to do some kind of firmware update now i've got another receiver that i picked up for it and this is the fs 1a10b and it's pretty similar type of a receiver as you can see it looks very similar and the only difference is that it has 10 channels instead of the 6 channels and although this is a 6 channel controller with a firmware update you can actually make it 10 channels and if you want to use all the controls there are 10 controls over here so you'd have to do that but otherwise it's a very simple little transmitter and receiver combination that's ideal for not only controlling radio control models but also for our radio control projects now as i said at the beginning of the video you can use these remote controls without a microcontroller or anything and that's what we're going to do right now i'm going to connect a couple of servo motors up to the connectors on the receiver i'm going to power the receiver with six volts from some batteries and we're just going to check it out no microcontroller involved now you can use servo motors i'm going to use a combination of regular servos and a continuous rotation servo if you have an esc an electronic speed control and a motor you could also drive it this way as well and so there's no hookup diagram this time all i'm doing is connecting a few things up to the receiver and then using the transmitter to watch myself control them so let's go and do that right now so i've hooked up four servo motors to my receiver and i'm just going to power it with a 6 volt power supply these four aaa cells right now the receiver is not connected to power i've got the ground wire disconnected because it's a good idea to always power your transmitter up before the receiver now three of these are just conventional servo motors this one over here is a continuous rotation servo and this will act very similar to an esc with a motor in that you can control both the speed and the direction with pulse width modulation now i've got my controller over here it's off right now now if i turn it on in the state that i've got it now with this stick up over here i'm going to get a warning saying that all my switches need to be up and i need to bring the throttle which is this control all the way down and now that i've done that the remote control is ready to go so let's power up the receiver over here and the remote made a sound saying that it uh has seen the receiver it's also displaying on the front of it right now the actual voltage from that battery and also its internal voltage now uh we can see basically what i've wired to everything just by moving the controls so if i move this control over here you see i can i can do the servo position with it now sideways i've got my continuous rotation servo so because it's in the center it's not rotating if i go to one side it rotates and the further to the side i go the faster it's going to go and if i go to the other side it'll rotate in the other direction and in the middle it stops and then i've got these other two servos one of them connected that's this one over here it would seem connected to what is normally the throttle up and down over here and finally i've got this connected when i go sideways and of course there are two other connections i can make and those are the ones of the pot i just don't have any servos connected to that right now but as you can see just by itself it's a very useful device if you want to control pulse width modulation control devices lx servo motors or esc's you really just need the receiver and the transmitter you don't need a microcontroller for anything unless you want to do something more advanced and of course we do so after this we will look at what it takes to hook a microcontroller to this and do a few more advanced functions so now that we've seen how we can control devices directly from the receiver it's time to bring some microcontrollers into the picture now we're going to do two different experiments and we're going to use a couple of different arduino avr style microcontrollers now the reason i'm choosing these older micros as opposed to something newer like let's say a raspberry pi pico is simply because the output of the receiver is 5 volt logic and if i were to use a newer microcontroller i would have to convert that to 3.3 volts and although that's very simple i thought it was one step we could eliminate over here now we're going to do a couple of different experiments in our first experiment we're going to use an arduino uno and we're going to use all six outputs of the receiver and connect that to six of the inputs on the uno and then we will use the serial monitor and we will look at the serial monitor as we move controls on our transmitter and see what the results are we're going to repeat the same experiment with an arduino mega but this time we are going to connect it to the ibus the serial output from the receiver and it has far fewer connections the reason we're going to need the mega is because we need a second hardware uart in it i can't use software serial for this particular code and the mega of course has more than one hardware uart whereas the arduino uno does not now another thing you need to know before we start these experiments is i've made one slight modification on my fly sky controller and it's a very simple modification that you can make in the setup by default all six channels are set to six of the different variable controls the two joysticks and the two pots up over here i've taken the last pot and instead i've mapped it to one of the switches over here and the reason i've done that is i wanted to show you how you can both pick up the results of moving a pot or a joystick as well as the results of moving a switch and so you will need to know how to do that if you're not sure how to do that with your fly sky it is in the manual and it's also referenced in the article that accompanies this video on the dronebot dronebotworkshop.com website so with all of that said let's go and take a look at our first hookup with the arduino uno for our first experiment we will require an arduino uno and the receiver for our remote control for the fly sky i'm using the fs-1a6b which is a six-channel receiver but the 10-channel receiver would work as well we'll begin by connecting the arduino's ground to the ground on the receiver the arduino 5 volt output will be connected to the vcc on the receiver arduino pin 3 will be connected to the signal output of channel 1. pin 5 will be connected to the output of channel 2. pin 6 will be connected to the output of channel 3. pin 9 will be connected to channel 4's output pin 10 to channel 5's output and finally we'll connect pin 11 of the arduino to channel 6 on the fsia6b and this completes our wiring now let's go and take a look at some code now this is the sketch that we're going to be using to read the data from the flysky receiver into our arduino and the sketch has been simplified a great deal by a couple of functions i found up on github that were written by a user named ricardo peva so thank you very much ricardo now we start off our sketch by defining the input connections the connections from the fly sky receiver to the arduino and then we define integers for the first five of those channels and if you recall the first five channels are mapped to either the joysticks or to the variable control of vra and so they'll have variable values that can be represented by an integer then we'll define a boolean for channel 6 because i've mapped my channel 6 to a switch swa and it's set by the way so that if the switch is in its default position which is pushed all the way back then the value will be a low and if it's pull forward it'll be a high now these are the two functions that i was talking about read channel and read switch and they make things a lot easier for reading the data that's coming in from those pins now read channel has four inputs there's the channel input itself the data you're trying to read a minimum and a maximum limit so we define the range that the control is going to go through and that's a very handy thing that can be any valid integers including negative numbers and then we also define a default value what value do we want to return back if we've lost the radial signal or something and we don't have a valid value from the controller so that's important to have this as well now the key to this function is the pulse in function pulse in measures a pulse width and we're trying to measure pulse width modulation so it's perfect for that we apply the channel input we're looking for a high pulse and we're going for a period of thirty thousand microseconds that's in microseconds and we're looking actually for a value between one thousand and two thousand microseconds but we'll first check to see if the value is below a hundred if it is then this is garbage data and we'll just send back the default value otherwise we're going to map the value between a thousand and two thousand to the minimum and maximum limit that we provided in the input of the function and we'll return that now read switch basically does the same thing but it's for a boolean so it has fewer inputs we have the channel input and then we have the default value what do we want it to be if we don't actually have anything to read then we see whether we need to use the default value or not this question mark by the way if you're not familiar with it is used as an if else statement it's just a shortcut and then we'll read the channel we'll go back and call read channel and so we'll apply the channel input we're going for a range of 0 to 100 and we'll also apply our default value over here and since we're going for a range to 0 to 100 if it is over 50 then it's considered to be high so we'll return a high otherwise we will stay low over here now in the setup it's pretty simple we're just going to set up our serial monitor because that's all we're doing with our sketch we're just going to read the values of the six different channels and display them on the serial monitor and we'll define all of our inputs as inputs and then we'll go into the loop and the loop is simplified because of that function so for each of these we do a read channel except the last one is a read switch and read channel we apply the channel that we're going to read we set the range and we're setting them between negative 100 and 100 so that's the values we'll expect to get back and the middle of all of our controls is going to be zero we're going to make the default zero for all of them except channel three now channel three is the throttle control and in normal operation when you start your transmitter you have to have the throttle pulled back so since we're going between negative 100 and 100 our default value for it all pulled back is going to be negative 100 otherwise we set a default of 0 which is the center of each control and then read switch we send it to channel and make a default of false and then we just go and print everything to our serial monitor delay for half a second and do the whole thing again so greatly simplified thanks to those two functions let's go load it up and take a look at it in action all right we're all set up the transmitter has been turned on and the receiver is being powered by the arduino which is also on and i've got it on the serial monitor right now and now you'll notice channel 3 has got a value of negative 101 and that's because the control is all the way down for channel 3. uh channel number 5 is my variable control over here so it's also got a value remember channel 6 is a boolean value for a switch so what we'll do over here is we'll take this control over here which should be channel 2 and i'll move it down toward the bottom and as you can see channel 2 is now down at the bottom and if i move it up toward the top you can see now we're at the top and you can get those values closer to 100 by using the trim controls on this by the way if i move it left to right we'll see the effect on channel number one and we can see that right now i'll move it the other way and it goes to a very positive value now channel three as i said is at the bottom by default and as i push it up it will get higher when i get to the middle it becomes a positive number and there we are all the way at the top over there and if i move it left to right that will affect channel number four you can see that and i'll move it the other direction there's channel four channel five is this control here this potentiometer and so if i move it all the way in one direction we get a high positive number and if i move it in the other direction you can see we get a low negative number and then channel six has been mapped over to this switch now by default it was that control but i used this to map it over to the switch instead so right now switch is in the up position the channel is reading a zero if i flip the switch down you can see it is reading a one so we're able to take the output of the transmit of the receiver excuse me and feed it into the arduino and measure it by measuring the pulse width and we can use these values of course to control our project but now we'll go and take a look at another way of doing this with only a single wire rather than all these connections to the arduino for our next experiment we'll be using an arduino mega 2560. we're using the mega because it has multiple hardware serial inputs and outputs and we're going to require that we'll also be using the same receiver we used in the last experiment we'll be making our connections to the ibus servo connector on the fsia6b and there are only three connections we'll be connecting the ground of that connector to the ground on the arduino the vcc on that connector will be connected to the arduino's 5 volt output and the data pin on that connector will be connected to arduino pin 19. this is the rx1 line and this completes our connections now let's go and take a look at the code we'll be using now this is the sketch that we're going to be using to read the ibus data and we're going to be doing the same thing we did in the last sketch just taking the channel data in and displaying it on the serial monitor however this time we're going to use a library in order to read the ibus data so go into your library manager and once you're in there filter by ibus and it's this first library here the ibus bm library which as you can see i've already installed you can install it through the library manager note that there's another use for the term ibus you can see down here it's also used for the infotainment system in bmw vehicles but of course we want this ibus for the rc protocol now there's a lot of neat examples that come with this library and you might want to take a look at them they include some examples for getting data back from the receiver side to the transmitter but we're just going to be using it to display the data up on the serial monitor so let's take a look at our sketch now our sketch again is going to make use of the same functions i got from github and we start off by including that library that we just got the ibus bm library and creating an object called ibus and then we have our two functions read channel and read switch now there's one difference in read channel now the source of the data we just use the ibus library which itself has a read channel function and we pass it the channel number now one thing you're going to need to note when working with this however is that this library starts its numbering at zero not one so what we refer to as channel one is channel zero over here our channel number two is channel one here etc etc so you have to keep that in mind the read channel function is the same as it was in the last sketch in our setup we're going to start our serial monitor and we also start serial one attach it to the ibus and that's where we have our connection from the fly sky receiver's eye bus output into our arduino and then we'll go into the loop and then the looper is going to cycle through the first five channels which in our case are zero to four so we do a loop and for each of the channels we're going to read it and we're going to set minimums and maximum values and a default value of 0 and then we're just going to print that out to the serial monitor then we'll go down over here channel 6 of course is our switch which is a boolean so we are just going to do read switch notice we passed a 5 to read channel switch 6 excuse me because of the way that they number things in the library and the default value of false we're going to print it out and we're going to delay by a short period of time and do the whole thing over again so it's a pretty simple sketch thanks to the library let's go and load it up and take a look at it in action all right so once again we're running our demo this time we are using the ibus output and feeding it into this arduino mega and uh let's start moving the levers over here now this should do channel two and as you can see as i go this way it goes positive and this direction it goes negative let's go left to right and that should affect channel one and it does channel one again affected and this one over here should be channel three you'll notice it was down at negative 100 when i get to the middle it gets to zero and when i get up over here it approaches 100 and if i move left to right we'll see the reaction on channel number four and there's goes channel number 4 to a positive direction this pot over here is channel 5 which is sitting at negative 100 as i move it up it approaches 0 and once i get past the midpoint it approaches positive 100 and there we go and then finally my boolean the switch that i mapped over here on channel six when i flip it it goes to a one and when i push it up it goes back to zero so as you can see this works pretty well the same way as our last demonstration but as you could also see there are far fewer wires i've just got the power and the one data signal over here so for reducing the number of wires this is a good way to go it also is supposed to have a little less latency than the other way and that's a little hard to see on the serial monitor but that may be useful especially if you're controlling something like a flying device and you need the fastest response time you can get so now we have seen two different ways of using the fly sky transmitter and receiver combo with an arduino so now that we've seen how we can use a microcontroller with our setup let's use that in order to build a project an obvious project to build is a robot car so that's exactly what we'll build i'm going to use one of those inexpensive robot car bases and i'm going to control it using my rc controller now i'm not going to make use of all of the channels on the rc controller so if you want to expand upon this and add more features to your car you can certainly go ahead and do that so let's go and construct a robot car now for our car experiment we're going to need an arduino mega 2560 a tb6612 8 bridge motor controller this is my favorite h bridge and i prefer it over the l 298n although you could modify the circuit to use an l 298 if you really wanted to we'll of course need our fly sky receiver the fsia 6b or an equivalent we'll need two motors for our car and i'm using two six volt motors you can use different voltages but you'll have to adjust the power supply an led any color that you like a dropping resistor for the led i used 220 ohms but again anything from 150 to 470 ohms would probably work just fine you require a power supply to suit your motors as i'm using six volt motors i'm using a six volt power supply and also a method of powering the arduino mega and i found the simplest method was just to use a nine volt battery in the barrel connector but of course there are many different ways that you can supply power to the mega we'll begin by connecting the arduino ground to the tb6612 ground we'll also connect that ground to the ground on the flight control receiver we'll connect the arduino's 5 volts to the tb6612vcc pin and again we'll connect the 5 volts to the fsia 6b vcc as well we'll connect the servo output from the ibus to the arduino pin number 19 as we did in a previous experiment we'll connect arduino pin number 13 to one side of our dropping resistor and the other side of the dropping resistor will be connected to the led's anode the led's cathode will be connected to a ground connection now we'll hook up the motor controller we'll hook arduino pin number three to the motor controller pwm a input we'll connect pin 4 to the ai2 input pin 5 to the ai1 input on the tb6612 pin 6 to the standby or stby input pin 7 to the bi1 input pin 8 to the bi2 input and finally pin 9 to the pwm b input now on the output side of the motor controller we'll connect the vm to the positive side of the six volt dc power supply we'll connect one of the ground connections on the tb6612 to the 6 volt dc negative side the motor controller's a01 output will be connected to motor a's positive lead the motor control a02 output will be connected to motor a's negative input we'll connect motor driver output b02 to motor b's positive and b01 will be connected to motor b's negative note that motors a and b are wired in reverse polarity this is because they are mounted 180 degrees apart on the car chassis and finally of course we'll need to connect our 9-volt battery or other suitable power supply to the barrel connector on the arduino mega and this completes our wiring now let's go and take a look at a sketch we can use for our robot car now here's the sketch we're going to be using with our car and i decided to have a bit of fun with the car design and give it two different modes that it could be used in and so could either be used in normal mode or what i'm calling spin mode now in normal mode you use the joystick on the right to control the direction that the car is going in you can move it back or forward or side to side and you use the left joystick and move it up and down for acceleration and spin mode which you activate using the switch that we mapped to channel 6 the car runs its motors in the opposite direction so this spin on the spot and you can use vra to determine whether it's going clockwise or counterclockwise and you can still use the acceleration to determine how fast it is spinning and so our sketch starts off by using the ibus library again and creating an ibus object then we get values for all of our different channels now we're using channels one two three five and six we're not using channel four which would be the left to right movement on the left joystick and then we define the connection to the led the car led and the connections to the motor controller including its standby pin then we define a few integers that are going to represent the value of our speed for the two different motors we initialize them at zero we also have a couple of integers that represent the direction the motors are going in whether they're going forwards or backwards and then we go into two different functions which are practically a dental cult to control motor a or control motor b and they have an input of the motor speed in the motor direction so we first of all determine our direction from this motor dir if the motor is going backwards we set in 1a and in12 on the motor controller low and high respectively and that moves it backwards otherwise we set them this way and this is how you control direction on the motor controller and then we just control the motor using an analog right by giving it pwma motor speed value now motor b is identical except it controls motor number b we've seen the functions already that do the read channel and read switch so we're ready to go into the setup in setup we're just using our serial monitor for debugging during normal operation we wouldn't bother with it we'll also attach the ibus to the serial one port as we did before we're going to define everything as output so we've got the pin mode for all our connections to the motor controller as being outputs as well as to the led and then we're going to keep the motors on standby for a couple of seconds and flash the led and the reason we do this in the setup is this to give everything time to give the receiver and the transmitter a couple of seconds to connect to one another and so we'll just flash the led briefly and then we'll take the motor out of standby by bringing it high and then we go into the loop now in the loop we're going to read the channels as we did before a few things to note uh channel 0 and 1 as we did before we're reading them from negative 100 to positive 100 with a default of zero which would be the center of the joystick and this is what determines the direction that the motors are going to be driven in over here is these two channels now channel 3 is acceleration and we're going to read it with a range of 0 to 155 and the reason is we don't want a negative number here this is this going to determine our speed and 155 is chosen because 155 plus 100 is 255 which would be the maximum speed that we can drive the motors at channel number five which is the read of four because of the way the library works is again negative 100 the positive 100 and that in spin mode determines whether we're going clockwise or counterclockwise and how fast we're moving uh channel six over here is a switch and we just have a default value of false which would be normal mode we'll print everything to the serial monitor for debug purposes and we'll start off by reading our motor speed values as being what channel 3 the acceleration control is reading so remember that can go from 0 to 155 we start both motors off the same speed and then we determine what mode we're running in are we in spin mode or are we in normal mode if that switch is set then we're in spin mode so we'll turn on the led to indicate we're in spin mode and we have to figure out whether we're going clockwise or counterclockwise so channel 5 that's the vra control will determine what direction we're going in so if it's a positive number we're going clockwise and we'll set our two motors accordingly over here with the motor direction otherwise we're going counter-clockwise and we'll set them this way over here and we can print the serial monitor for debugging purposes and then we're going to add the speed that we get from channel 5 to our existing speed and we do that by adding it using an absolute function because remember this value can be from negative to positive 100 and we don't want a negative value that'll decrease our speed so absolute this brings back a positive value regardless of whether it's been fed a positive or negative one now otherwise we look at our switch and see we're in normal mode so we'll go and we'll turn off the led and now we need to determine the forward and backward direction with the channel 2 value channel 2 is the up and down movement of the right joystick so if it's positive the joystick is going forward and so we'll set our two motors note now the two motors are set to the same direction because we're in normal mode and we'll print forward to the serial monitor otherwise we're going to set them backwards and now we have to add the channel to speed uh to [Music] the speed that we're going right now so we'll take the speed on channel 2 and again we use the absolute value because it could be negative or positive and add it to the channel three speed that we already measured earlier the acceleration speed now we look at channel one now channel one is going to determine what direction left or right we're going in because this is the left or right movement of the right joystick and interestingly enough for channel for this channel on channel a we minus the speed and on this one we add it and you'll have to work that out in your head because remember this value can be anywhere from negative 100 to positive 100 so minusing a negative number actually adds it and adding a negative number subtracts it so this will offset the speed on the two different motors so we can steer everything and then we get out of there and for both of these whether we're in spin mode or whether we're in normal mode we want to make certain our values end up between 0 and 255. in normal mode they might not because remember we're adding and subtracting this offset over here we could go over 255 or under zero so we're using another handy arduino function constrained to keep those values just between 0 and 255 and then we'll go and we'll drive our motors tell the serial monitor we've done that put a little delay in and go back and do it again so it's a long sketch but it's actually a pretty simple one so let's load it up to our car and give it a test drive and so i'm ready to give my car a test as you can see i've got it up on blocks right now so to speak just so it doesn't run away from me on the workbench while i'm testing it out it's just built on one of those little 12 dollar car chassis you can get over at amazon or ebay i've got most of it tie wrapped including the receiver and the 9-volt battery that's underneath here the arduino uno is bolted down here and on top of it i've got a shield that has a solderless breadboard on it so i can prototype everything and buried within the wires you can see the motor controller you can see why i like this motor controller so much it's so tiny it doesn't require a heat sink because it really doesn't give off any heat it takes all of the energy from the battery gives it to the motor thanks to the fact that it uses mosfets and not bipolar transistors like the older l298n used now uh we're ready to go here except for powering it up which i can do with this barrel connector over here from the 9-volt battery but first we'll better power up our transmitter so we'll turn that on it's powered up so let's give some power now to our car and you can see the led flashed and everything and we should be ready to go now we're in normal mode so if i push this forward you can see my wheels are going forward and if i bring it backwards they're going backwards if i go all the way to one side i've only got one going because i'm steering over here this steers the other one and i can do a combination of both now this does the acceleration it can be combined with this so that i can go up to full speed forwards and backwards and also steer off to the side in which case one wheel will move faster than the other but the other one isn't stopped and that seems to work in normal mode very well now we'll use the switch and we'll switch into spin mode and in spin mode you can see the the motors are moving a different direction they're being controlled their direction by this pot here if i move this way they go the other way so this is counterclockwise and move to the middle it stopped over here it's clockwise and again i can use the acceleration to make it go faster directions so that seems to work that let's just center that right now so it stopped and take this off of its blocks if we can and should be able to run it down over here i would think let's just spin it one direction and there we go and the other direction seems to work i can speed it up that's pretty good so put it back into normal mode over here and drive forward and drive backwards and turn it a bit turn whoops get it back in your field of view we'll turn it this way in that way it seems to work pretty well now of course with one of these transmitters you can do much more than the a couple of inches that i was away from the receiver you could actually under good conditions get a kilometer or more range so this would be a great little robot car to drive around outside but at any rate you can see how easy it was to build using distant arduino and a very inexpensive fly sky uh transmitter and receiver and so that wraps up our look at rc remote controls i hope you enjoyed the video and that it's opened your eyes to a number of things you can do with rc remotes and remember you don't just need to be controlling motors anything that you can basically drive by changing the numbers or turning something on and off can be controlled by these so think of things like leds or changing the color of rgb leds remotely you can do a lot of things with these wonderful little devices now if you want some more information on today's video or if you want to get the code that i used head over to the dronebotworkshop.com website there's a link to the article accompanying this video right below the video so you can just click on that while you're in a clicking mood and if you haven't subscribed to the youtube channel please do that all you need to do is click on the subscribe button and also click on the bell notification and assuming that you've enabled notifications in your youtube and remember a lot of people haven't so you'll need to check that but if you've done that you'll get a notice as soon as i make another video now on that subject i haven't made a lot of videos recently and a lot of people might be wondering what's happening i've had a few people inquire and i appreciate that but everything is fine i've been working on a big project and i want to show you something that has to do with that big project right now now this is really not together yet but it looks like this and when i said big project i mean that and for those of you who are subscribed to my newsletter you are about to get a newsletter that describes exactly what i'm doing right now so if you're interested in that you can certainly subscribe to the newsletter it's absolutely free i mail them out every once in a while just to let you know what is going on and if you want to discuss today's video well head over to the dronebotworkshop.com forum it's the best place to discuss this video all of my videos and just about everything electronic with a bunch of like-minded individuals who are always willing to help you out with your projects so until we meet the next time please take care of yourself please stay safe as always and i will see you again pretty soon here in the dronebot workshop goodbye for now [Music] you
Info
Channel: DroneBot Workshop
Views: 38,314
Rating: 4.9720812 out of 5
Keywords: arduino remote control, radio control, arduino project, flysky fs-i6x, flysky arduino, flysky ibus
Id: BACBNgaCnJU
Channel Id: undefined
Length: 47min 52sec (2872 seconds)
Published: Wed Aug 25 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.