arduino joystick library
And you can have that to function as a game control to play a computer game which is the main one of the main purposes of the uno joy project. I think, and in that particular video. I did things on Linux because it’s easier for me to make this video recording stuff on Linux and also because I use Linux as my main computer and I wanted to play a game which is a radio controlled helicopter game. And for that I wanted to use the four channels of a radio control transmitter, so I had the receiver feeding data into the Arduino, so I could do things wirelessly and at the end of that video I made a sort of a promise to do this. Also on Windows, because the windows way of doing things is a little bit different and it’s a little bit more complicated as you’ll see when we go through it, but what I’m going to do? What the reason that I want to use it on Windows is to play a driving game and I wanted to have a steering wheel. So this is my steering wheel here. I also need a accelerator and brake, but we’ll do that later. So the actual input side of it is going to be quite a bit more simple, this time, because I’m not going to have any wireless stuff so I’m, just going to have to plain old analog potentiometers like this to use as input.
But the procedure is roughly the same and just to recap, if you haven’t seen that other video, which I will put a link to here, basically, instead of uploading a sketch on to the Arduino, the main chip of the Arduino, we need to upload a sketch onto This other little chip here and that will tell the Arduino that, when it’s plugged into it, will tell the computer that it’s a game controller instead of an we know, and to do that, we need to be in a special mode called device firmware, update mode, and We can do that by you can get all the all the gory details by watching my last video on this topic, but we just short briefly short, the two pins on the left side there of the six pin header, and then we upload the sketch to this Chip rather than that chip, so I won’t go on too much about that all those details, but we will need to look at the procedure for doing it. So if you go to this page, you can get here just by googling uno joy and you should find this. And if you go to this getting started page, you will find on there a link to few things that you need. So obviously you need the arduino ide before you can do anything with arduino, so you’ll have to have that installed and there’s some information here showing what i just said basically and you’ll also need to have this.
The Atmel flip tool, which you can get by clicking that and that will take you to this page here and then come down and you’ll need to get one of these ones for windows. If you already have the Java Runtime environment included installed on your computer, you can probably just get this one here. Sorry this one! Otherwise, you can just get that one so install those to the send the Arduino ID and then you would go to downloads on the main window. Joy section – and this is the one that I got here – ooh no joy for Windows because I’m using an Arduino Uno. You can also do this with a Leonardo and a 80 mega as well. I think the two five six zero board as well, I think anyway, so let’s flip over to Windows. Now – and here are those things that I have downloaded and I’ve already unzipped the Nigeria project – and this other thing that we’ll get to in a second but let’s just have a quick recap of the procedure for tuning our Arduino into a joystick. So if I go into this uno, joy, win, folder, we’ll go down here and we’ll see turn into an Arduino and turn into a joystick. So these are the two batch files that we can run to do, whichever turning into that we’re trying to do, and over here on the left you can see at the moment my Arduino is plugged in showing up as comm 13 and it’s, showing up as an Arduino Uno, so this is the state that things will be in before you start doing all of this stuff.
So to turn our Arduino into a joystick we’ll run that batch file, but first while it’s still an Arduino. We should upload a sketch to the Arduino to have it read in the inputs and relay them as if it was a gamepad. So that is found in this uno joy Arduino sample folder, and this is just a regular Arduino sketch that we’re going to upload to the main chip on the Arduino as normal. So everything’s normal at this point. So if I just open the Arduino IDE to have a look at this, we don’t really need to look at it at the moment, so I’m just going to check that I’m doing Arduino Uno on comm 13, and then I upload that sketch. So this is going into the main Arduino chip. At the moment, you just check that that looks all right: okay, that’s good! Now, when we’ve done that we can go back to this main folder of the you know, joy project and I’m going to get ready to turn into a joystick, actually I’m going to intentionally forget to do something here. I’Ll just run this, and so you can see what happens when you forget to do something. So we have a bunch of red text and it says attempting to reflash for an arduino uno, revision, 1 or 2 fail trying for arduino uno revision. 3, fail fail, fail and then it says is the I dunno plugged in yes, it is is: is it in Arduino DFU mode? Oh no it’s, not so that’s.
What I forgot to do so I’m, just going to click any key to exit that and to get it into DFU mode, as I mentioned just before. You just have to short these two pins on the left side there, and you should see this light sort of flicker. I think it goes off and then it comes on again or something sooo see what happens flickers a little bit and then it comes back on so now when I try turning into a joystick again, we see lots of green and green means. Good and everything looks great and it says now: you need to unplug the Arduino and plug it back in, but it will show up as a joystick press any key to exit. So now, if I unplug that and plug it back in according to the documentation, you should see it’s showing up here as uno, joy, joystick, or something like that now, I’ve, never seen that, I didn’t see it on this computer. This is my my laptop computer here and I pretty sure I didn’t see it on my other computer or well the the Linux computer that’s windows. When I change the hard drive, I didn’t see it on that one either, but don’t worry it’s a most likely still. There you can, oh this, to scan for how they changes no that’s interesting, but it doesn’t. I tried this before, but it doesn’t it still. Doesn’T never show up here, yeah, okay, so you might.
You may see that, but don’t worry. I think we’ll still be ok, because I go back to my folder, where I put the things that I downloaded yeah. Unfortunately, at Linux and Linux, this was as far as you needed to go. You could probably start using it as a game pad now, but on Windows, what happens is at least for a lot of games. They want to use an Xbox 360 controller, which this is obviously not so what I’ve been using to get things to work? Is this really neat tool called? Where are we? What was it gone here? Okay, so there’s, this tool called taco edit or something – and you can get this by googling for Xbox 360 emulator, or maybe you could just type that in x360 seee now. This is a really really neat little tool and the reason that this tool exists is that a lot of games like to use the Xbox 360 controller because it’s a very common standard, at least on on Windows for games. But if you’re doing anything, weird like we’re doing in this video or if you just don’t, feel like spinning 45 on it, an Xbox 360 controller and you bought one of these cheap nasty knockoffs like I did for 16 dollars. Instead, you may have trouble getting your games to run if the game is expecting to see a real Xbox, 360 controller. So originally I got. I first came across this this emulator software for to get this game paired to run, but it turned out to be very useful for getting the uno joy to run as well.
So all I’ve done to get this as I just downloaded one of these, whichever one is appropriate for your computer and that’s. What I have here – and I just unzipped that into a folder on in here so when you unzip it you’ll, just see this Exe file. That’S, all there is in it so I’m going to run this in a second and show you how the setup looks but I’ll just also before I do that, show you what the output we get from. That is when you run this, and you set the settings correctly, it will output a dll file and, in this same folder and another file, an ini file which contains your settings and you’ll, take those and you’ll put them in this case. The first time I tried this was to play spelunky, so this was in steam. If you have any games from Steam, you’ll probably find them under program files, steam, appcache, nope, what steamapps that’s right and in common and then spelunky. So if I go into the spelunky folder, where spelunky is installed, you’ll see we have this DLL X, input 1.3, DLL and it’s not actually made by Microsoft. As you can see, when I mouse over it, it says: company X, 360, CEO, Google code, comm, so that’s. Obviously, not the Microsoft’s official one, and then we have X, 360 seee ini. This is just a text file that contains some settings that are specific to your controller and this X input.
Dll is here because the way that dynamic loading of libraries works on Windows is that whatever folder the executable file is in, it will first look in this folder to see if it can find any of the named DLLs that it’s looking for so this file here Will I think this will be in C Windows System or something like that, which was where it would normally load it from? But you can override that or bring this file into a higher priority in the loading list by just placing it in the same folder as the exe file itself. So this DLL is going to be used instead of the normal windows, one so that’s going to override the normal behavior, and it will treat our fake gamepad as if it was a real xbox360 controller. According to the settings that are in this file. So so, when you’re all done with these settings, I’m not going to come back to this again, but just keep in mind that when we’re done with all the setup that we’re about to do, you’ll need to take these two files and put them into the same Folder, as whatever game it is, that you’re trying to run so you if I wanted to play spelunky I’d, have to put it in this folder and if I wanted to do that, do it with terraria. I don’t also have to put it in to this folder. As well so wherever you need whatever folder the exe for the game is then unique, that’s what you need to put it all right, so let’s run this and see what happens now saying the X input 1.
3 DLL was not found. Do you want to create it? Whoops so I’m going to say create yeah. We just canceled this in, if you’re using this, just on the off chance that you do have one of these knockoff controllers and you’re, trying to set that up. Instead, what you can probably do at this point is search automatically for settings and also check the search, the internet check box, and it will most likely find the settings automatically for you that’s. This tool is quite well maintained and very popular, so give that a try. I’M going to cancel that, because I know that my crazy Arduino thing is not going to be found anywhere else so I’m just going to cancel that all right so back to here, I’m going to click create because I want this X input 1.3 DLL to be Created so now you can see we have the two, what we have those two files that we saw in the spelunky folder just before the crash: oh right, counselor, okay, this is also okay. At least I found that it doesn’t matter so I’m, just going to click. Okay, through that now the first time you run, this you’ll probably find that there’s a red marker. Next to this controller tab here and all of the buttons are all grayed out on this it’s, like a preview display, so you can see what buttons it’s it thinks you’re pressing. But if you go over to the right hand, side in the bottom right tab, there is a tab.
Well, there should be a tab called uno joy joystick. So this is the first indication that we can see that actually proves that this uno joystick thing worked properly. So if you don’t see this at this point, then I don’t really know what the problem would be or how you could fix it. I’M. Sorry, but I found that, at least in the case that I’ve the both cases that I’ve traded for even when there’s nothing showing up in the device manager here, this Xbox 360 emulator program is a little bit smarter and manages to find it so any I’m going To click on here and then we can see some raw values, so you’ll probably see the analog values sort of twitching around a little bit, and these are the raw values that it’s reading in from all of your sliders or the analog joysticks. And as I said, oh actually, no sorry yeah can’t do anything with that. Yet okay, but I found that if I just clicked save here, not necessarily on this tab, just just anywhere in this program, just click Save and then exit and then run it again. And I just sort of discovered this by chance. I almost gave up on this a few times, but I found that when I saved and closed the program and run it again now, we can see that the light on this controller, one tab is green and the buttons are showing up here in colors.
So something inside this program got set a little bit more properly than it was before, and now we can do the next part of the process, which is figuring out which of these X’s and buttons are the buttons that we have on our fake controller. So the easiest thing to check is a button, because buttons don’t really have a direction. So what I’m going to do is make so that’s the earth that’s ground here and I’m, going to make digital pin to my button a so the way we can do. That is so. This is but an a here and you can manually select what input you want that to come from, but I’ve found that one really really neat little trick that this program lets you do is just click on this record option. Let me just see if I can do this. Hopefully we can see both of these things happening at the same time and we can’t okay. So what I’m going to do is I’m, going to click record and then I’m going to put the digital pin 2 connection on there. I’Ll just see. If I can do this: okay, okay! So now you see button 4 is showing up there and now, if you watch the visual display of button a there you’ll see that by connecting digital pin 2 I’m pressing button a on the controller. Now, why is it button 4? I guess that’s, because if we go back to the you know, joy sketch perhaps button for was digital pin, 2 or something so digital pin 2 is being given triangle triangle sort of triangle.
That sounds like playstation nomenclature doesn’t it anyway, so you don’t really need to know specifically, which digital pen is which, as long as you use that record feature, okay, so let’s see if we can do that for our dial so I’m going to do the same thing And I’m just going to turn the dial fully to one side or the other so I’m, just turning it fully to the left at the moment and I’m going to make this go on to stick axis X, so I’m going to do the same thing to record And I’m just going to turn that dial all the way to the right, and we can see that it has detected that, as I H X is 2. And if I understand this correctly, the eye is four inverted and H is for 12. If you want to set these manually, you can come down here to axes, and so IH X is 2 would be. Inverted. 12 X is 2, so this is the one that it has automatically detected for me to be that axis now, it’s see if it got. What I wanted, if I turn this dial doesn’t, look very good. Does it nope that’s, not what I wanted and if you want to look at the raw values at this point, you can also see what values were getting there. So you can see when I turn the axis X here. Is this value twitching a little bit there, but it goes from basically zero through to 65535, not sure what’s touching, like that it wasn’t twitching like that, just before that’s, better okay, so it’s a bit more solid, zero.
There I’m not sure, maybe I’ll hit a funny connection there, damn it anyway, so that’s that axis not quite what I wanted, though, so rather than IH X, is two might just try that again. It gave me something else before it’s a bit it’s a bit finicky. I’M, going to just try turning it a little bit slower, nope now it’s, given me a Czechs s2 and as I move it it’s kind of jiggling everywhere. Okay, I think I figured out what the problem is here when you do this record. What it’s doing is it’s looking at these raw values here and it’s, just seeing which one you’re changing and then it’s recording that as that axis. But the problem here is that, even though I’m changing this one here intention, my intention is just to change this top x value. The other axes here are all sort of twitching around and they’re moving as well, and when I turn the dial a bit we can see everything is moving all at the same time. So, instead of picking out the correct access, just picking one of the wrong ones, it seems – and I think maybe I just got lucky last time – I tried this and it picked the correct one. So the reason for that is, I think I commented on this in my previous video as well – is that I only have analog, pin zero actually connected to anything at the moment and analog pins.
1. 2 amp 3 are just floating, so you could either connect these to ground to make them shut up, or you could do what I’m going to do, and I just sort of tried a couple of the other axes, and I found that when I set it to X is 3, and now, when I turn my dial, we get a much smoother movement of so I’m. Looking at this here now again we get a much smoother movement of that axis, so that’s. What I want from side to side like that it’s going the wrong way. So what I actually wanted was inverted axis 3 and now I should have the correct direction and the correct movements, and if you find that it’s not going far enough, you might be looking at one of these half axes. So let me just try and vote it. Half axis 3 and see what that gives me that’s funny it doesn’t change. Alright! Well I’ll keep that. So that is how you can set up a button and an axis and then, of course you click Save and that will write develop though these settings into this dot ini file, so that then you will copy that into your game. Folder to run to play this car driving game that I’m going to do. I need another axis to function as my throttle and brake so I’m going to use this radio control gimbal can potentiometer from inside here, because this one doesn’t have a return spring.
So I kind of want to use this one as my throttle so I’m, just going to connect that up and I’ll show you perhaps one other little thing that you might come across a problem that you might find that we can work around with this kind of Potentiometer, okay, now I have connected both of these potentiometers to the Arduino, so this is going to be analog 0, and this is analog 1, and I have also in the emulator program. I have determined that the throttle stick here is inverted access to, as you can see, the little green cross here is moving up and down when I move the stick. However, now this is the problem that I mentioned: it’s not moving much at all, and the issue here is that, just in the way that this potentiometer is made, we don’t get a full range of the values. The voltage that it reads on the wiper doesn’t go from 0 to 5 volts, clean and fully so these ones. Here you often find that they do go from 0 to 5 volts. So we get a full range of readings from the analog. Read that the Arduino is doing so. What we need to do is calibrate this joystick here so that we do know the full range well it’s, not reading the full range. We want to know what range it’s reading, because we know it’s not reading the full range. So one way we can do that is in the sketch that we uploaded to the Arduino that does the reading of these values.
We look down at the bottom of that we’ll see what’s going on with these stick readings and they’re all being done with analog reads. So this is my steering wheel and this analog one is the throttle that I’m having problems with. So I want to see the values that I’m getting from that. So what I can do is in the setup function. I can do oops serial begin and having problems with keyboard mappings here, so I can begin some serial output and then down here say I can do serial print line and then analog read a so a1 is what we want to know what’s going on now to Get this onto the Arduino: we have to go through that process where we turn it back into an Arduino and then upload it, and so on. So to do that. Of course, we’ve got to short that pin again they might just. I just closed this program. First, alright, so I’m going to short the pin and then in this folder I’m, going to click turn into an Arduino that should run with lots of greens and then we upload, oh man, there’s, so many steps. Now I have to do this and then it should come back as an Arduino Uno there. Now I can upload the sketch now this point. I just want to open my serial, monitor and look at the values that I’m getting so and what we got when I push it right down the bottom I get 620 and when I push it right at the top, I get 400 so 400 to 620.
Is the range it’s giving me so you can see it’s clearly not zero to 102. Three like it would be four for this type of potentiometer. So what is that 400 to 620? Okay, now, what I can do is, instead of using the normal range that analog read, would give me here, which is 0 to 1, o 2 3. I can instead use map, so I can map the value that it’s giving me from being between 400 and 620 to being between 0 and 100 to 3 loops need to break it, so that should change the range from 400 to 622, the full range I might Actually, just go a little bit lower ‘8 and a little bit higher on the high range 622. So that’ll make sure I don’t get any negative values coming out of this. Hopefully, and then I’ll just take away that stuff that I had for my debugging output. Like get rid of those and then I will upload that to the Arduino and then we need to switch it back to a joystick again now. So we short the pin and then click turn into a joystick and plug replug and then go back to the emulator set up and with a bit of luck we should see now that we’re getting the full range so back once again, I’m. Looking at this here, we’re getting the full range of movement vertically on that axis, so that’ll give us a real good throttle and braking when we’re driving our car, instead of just a pathetic one, all right well that’s about it, really of course there’s a lot of Other controls and inputs you could set up for, however, you like, and if you’re watching this video thinking.
Why would you want to use this shitty setup like this? Of course, the point of this is that this little potentiometer here could just as well be a full sized steering wheel that you use to turn to drive, and this here could be a pedal on the floor that you use to. You know, drive your car or could even be two pedals really, and you know you could have a handbrake beside you that you use as your handbrake button. Instead of one of these stupid little wires. You know you could set up a really nice little system for say a flight simulator or a driving simulator I’m. Not going to do that, but I’m saying like this little crappy setup. Here is not necessarily the end goal of something like this it’s. You can set up whatever kind of system you want if you put a bit of time into it anyway, so for the rest of this video I might just put in a little bit of driving in the dirt rally game and I’ll see if I can patch My you know fingers doing stuff on top of the videos so that you can see that I am actually managing to play the game using this crazy setup anyway, thanks for watching see you next time, five, four three two one left 683 den great sense into left. More into right tuned down John made me pass Junction let’s fix 3200 kept. It left don’t come 130 right.
Six off caution, braking bumps of humor into camp in right; 100: point why, from London into that fall ball? What progress for some right sex into a media habit left our poor, Hamlin right 60 right more times three, No and like to have long. He made bumps and left three pass: junction: three games right, foremost, junction pressed left boy and right 1, through 10 40 Jen 100 motion breaking turkey, 100 Taekwondo, 100 person, 6950 brain sixty crest right, six, plus junctions left three long downtown sixty keep right thanks doctor a Seacrest 130 of Junction turn right. 60 left X continues. 150. Thank you. My flavor turn right back up immediate left, one don’t cut 170, one more into turn like one dead. Don’T come multipass, junction 18 for long and point six times. Three Pass Junction opens 100 and modern young men, junction box outside 60 crafts.
arduino joystick library Video
arduino joystick library news
Posted on Thursday January 18, 2018Flying The Friendly Skies With A Hall Effect Joystick Hackaday … Continue Reading »
720 Strategies Celebrates a Milestone: 20 Years of Excellence in Public Relations, Public Affairs – PRNewswire
Posted on Friday July 19, 2019720 Strategies Celebrates a Milestone: 20 Years of Excellence in Public Relations, Public Affairs PRNewswire … Continue Reading »
Posted on Tuesday August 23, 2016How to Make a Joystick-Controlled Laser With an Arduino Lifehacker … Continue Reading »
arduino joystick library Social
🔬 Now that you’ve gotten your feet wet, dive into the kit and enjoy all nine experiments. Order yours today: http://bit.ly/2MnQ7fr
Originally posted 2016-06-08 20:35:27.