The Ultimate Arduino Library Installation Tutorial - All-in-one Video!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
are you trying to figure out how to install an Arduino Library well I'm going to show you three different ways on how to get it done I'll show you the easy way and then I'll show you the manual way you can do it if you're getting some like weird library that you want to include all right so let's go ahead and Jump Right In All right so here I am in the Arduino IDE and I just want to say real quick what the heck is an Arduino Library mate you know you probably know this but let's just cover our basis so basically in Arduino library is just some code that some other programmer or programmers have written and they've packaged it up in a very specific way and then they make it available to anybody who wants to use Arduino to like use their library that was pretty darn generous of them for them to do that a lot of these people are extremely experienced and they may have spent even years working in perfecting this code and what's great about this is when you use Arduino libraries it allows you to leverage other software developers expertise because like I mean to be honest if you want to use some complicated piece of Hardware you know like some electronic sensor or actuator you might actually have to study like the manuals for that pretty indepth to try to like develop the software to run that appropriately right but luckily all these other folks they've already done all that hard work and they're making that hard work available in the form of an Arduino Library Okay so Arduino library is code packaged in a specific way that's made available to us Arduino programmers okay so that's what Arduino library is here's what's interesting the Arduino IDE either ide1 or IDE 2 both of them they come pre-installed with some libraries so if you go up to the top of your Arduino IDE and you go to sketch and then you come down to include library and you scroll over here you see there's this little header here it says Arduino Library okay so this little section right here these are libraries that are pre-installed with the Arduino IDE so I don't have to download the e prom Library I don't have to download the uh human interface device library or the software serial these these ones I they're already there right so if I wanted to include those all I would do is click it and you know what I'll just click this I'll show you what happens I'll click e prom so see how I clicked eom and then this little line showed up right here so what this line of code is doing is telling the Arduino IDE that it wants you to get this file this this e prom. because this is just like a program file right it says get this file and literally I want you to paste it up in here when it's time to compile the program so like you know if you're pressing the verifier or the upload button right it's going to take the code that's in E.H and it's literally going to paste it in here now you won't see that code getting pasted like it's going to do that behind behind the scenes but that's that's all that's happening is taking this code sticking it at the top all right okay so what we just did here is we didn't install the eom library we just included it in our sketch right so now in this sketch I can reference functions in the e prom library but if we want to actually install a library into the uino IDE one that didn't come prepackaged with it then um we need to pull in that library from usually like the internet right and that there's lots of different ways you can do that with the Arduino IDE okay but let me just show you real quick I'm going to go back to sketch and I'm going to say include Library see this section down here under Arduino libraries where it says contributed libraries when you pull in a library from a third party from an outside Source they're going to be listed here right down here so these you can see I've got a ton of different libraries in here probably not much compared to a lot of you know some people probably have a ton maybe you don't have any right now you're just getting started doesn't matter right okay so when we import a library it will show up here under contributed libraries so okay how the heck do we import a library well I want to put a quick pause on this okay because and this is going to annoy you and I'm not trying to be like super annoying as my kids would say but here's the deal in life sometimes you need to do like pre-work before you do the work okay so like the work itself is supery easy but what really matters is the pre-work like setting it up right okay so what am I talking about well before you just willy-nilly start importing libraries into the Arduino ID you need to do a little like research on the library right like why why are you getting the library and which one are you getting so maybe for example you have a project and you want to include an accelerometer into the project okay so what you might do is you might just like oh I'll just randomly import any accelerometer library right a better approach though is to do a little research on which accelerometer Library you want to pull in or maybe you already have the part number you know like you know the exact accelerometer you want to use so maybe you would Google like Arduino library for you know this specific accelerometer right you might get like multiple options and then what you want to do is like compare which one you think's going to be the best now as far as like making that decision that's kind of Beyond on the scope of what we're going to talk here if you want to learn about that stuff check out programming electronics.com we've got training that dives into all that kind of stuff but you again you just want to do the pre-work okay so now let's say you've like okay I know what library I want to get I'm going to go ahead and import it so here's the easy way to do it and first I'm going to show all the ways in Arduino ide2 and then I'll show you in Arduino IDE one which is still both of them are still used extensively okay over here on the left there's these icons and all you have to do is click the one that looks like a bookshelf now before you do that what's interesting a little little known Arduino Easter egg if you zoom in on this icon they've made they've made some interesting uh selection of books here you know anyway okay so you click this and this pops out this little shelf pops out and you see there's this huge list right so this huge list right here are all the Arduino libraries that third parties have contributed to the Arduino e e system essentially right and you know like Arduino has a mechanism by which people can contribute libraries in fact I contributed one let's see if we can find it here chat chat GPT I think that's I'm trying there it is chat GPO by Mike Chas see so I've already installed that library but anyway there's a mechanism and it's actually pretty easy to contribute a library to the Arduino ecosystem anyway so what you do is you search for your library so let's say I'm just going to search for Excel or um not sure I'm spelling that right let me just okay here we go now see that this list has been filtered you know that's pretty common and I've got this massive list of different libraries for you know uh looks like yeah most of them are for accelerometer stuff right so I've got to know hey which one do I want now let's say I've chosen the one that I want and let's say I'm working with this uh LSM 60 s Sox okay all I'm going to going to do is Click install like that's all I got to do now notice you can pick the version that's kind of cool uh I think it defaults to the most recent one okay you can click more info this will take you to like the GitHub page where this code repository is hosted but I'm just going to click install and then down in the right hand side it says hey I'm installing this and gives you some information on the output okay and that's like the easy way to do it all right now what actually happened though I pressed some buttons like I don't know threw some text at me like I don't know what actually happened okay so here's what happened the Arduino IDE it went out to the internet and it downloaded a file it downloaded some code and then it stuck it in a very specific place and I'm going to show you right now where that place is okay so there's this concept with the Arduino IDE and it's called the Sketchbook folder okay okay now what I'm about to tell you is not esoteric in any way shape or form this is actually really important for you as you learn how to develop Arduino so uh I'm not talking about like some weird like obscure thing okay so the Arduino Sketchbook folder is where all the files that you write all the Arduino programs you write are going to get saved in this folder okay and this folder is usually under like my documents Arduino okay so that folder ER called Arduino in my documents that's like the default location that is the name of your Sketchbook folder and to check this all you do is you go to settings or preferences all right and right here it says Sketchbook folder location and you can see mine is in users Michael CH documents Arduino so you know it might be my documents documents whatever so this is my Sketchbook folder so now let's go to this Sketchbook folder all right so I'm just going to go ahead and um I'm going to take a look at this Sketchbook folder okay so here I am in my Sketchbook folder so Arduino is the name of my Sketchbook folder probably is the name of yours too again that's the default setting when you install the Arduino IDE and so I'm in my Sketchbook folder and inside everybody's Sketchbook folder there is a folder called libraries and this folder right here is the magical place that that code that you just downloaded that the Arduino IDE downloaded for for you this is the magical place that code is going to go so hey let's go ahead and take a look at this uh mysterious place okay so what was that thing we downloaded what did we say it was uh Arduino LSM 63s Arduino l oh bam there it is okay wow that's cool all right so now I'm going to open this folder let's take a look uh what's in here okay so in an Arduino Library folder you're going to have some specific other folders okay so one very common one is the examples folder and in the example folder is where they have some example sketches okay so they usually have an example folder not always but usually and here will be those example sketches okay so another folder they might have in here is called SRC that stands for Source that's like where the source code is okay so when you click this in here this is where they're going to have a h and a CPP file so CPP that would stand for C++ uh andh is the header file okay so these are just like code files and they are what are specifying like the functions and the code that essentially make up that Library let's look at some of these other files here all right so this one keywords. txt this keywords file this identifies which words that the library author want to be highlighted in the Arduino IDE like you know how some of the words in the IDE change colors you know they're like keywords and stuff well you can do that for contributed libraries you can make like the word change color which is pretty cool all right so you would do they would do that in uh keywords. txt okay and then there might be some other stuff in here it looks like they've got some documentation in here so this is kind of interesting stuff now importing an Arduino Library into Arduino ide1 is just as easy all you do is go up to sketch include library and you click manage libraries and what it it does is it's going to open up a window so instead of some like shelf coming out of the side it just opens up a window here and this is your library manager and you're going to do the exact same thing usually it'll kind of like update your list of installed libraries here and all you're going to do is type in what your searching for and then it's going to filter them just like Arduino IDE 2.0 so same exact process I'm just going to wait patiently for these uh libraries to update all right so I can just search for Excel and now stuff will come up for accelerometers okay and then you would just click install same ex exact thing now here's what's really cool Arduino ide2 and Arduino ide1 you can have them installed on your computer at the exact same time and they share the same Arduino Sketchbook folder with that same Library folder so if I installed it on Arduino IDE 2.0 it's going to be in when I go to Arduino 1.0 same exact thing okay so I just showed you the easy way of how to install an Arduino Library so let's say we installed that library now we both know like hey where did that Library actually go well it's just in your Arduino Sketchbook folder under the libraries folder okay so that's where the code lives now what if we want to actually like add it to our program and start using it well then we have to include the library in our sketch just like we did before so now if you go up to sketch include library now we can go to contributed libraries right because that Library we looked at we added it right we can come down here and let's look what was it it was called Arduino here it is right here so I'm just going to go ahead and click that and Bam it just inserts that right there now that's just a little like handy helper thing right you don't actually have to do that like I could just manually type out you know include and then uh you know I could type this out right there's nothing magical about going to sketch include library and then like pressing it literally just inserts the the code that you need for you know or that line of code right so you could manually write it out if you wanted to anyway it's just trying to like save you some button clicks maybe save you from mistyping it okay so that's that so now you know how to install library and how to include it and then you can actually start using the code in here all right so here's the deal sometimes you might have to install in uino library manually okay now it's pretty darn easy to do and I'm going to show you two ways to do it okay now the reason you might have to do this is because maybe the third party that made the code maybe they have not submitted it to Arduino yet so that could just be one of the reasons and so when you go searching for it it's not in that Library manager you're kind of like hey what gives well you're just going to find it somewhere else right like maybe it's on their website or maybe it's on GitHub it just hasn't been submitted yet so let's talk about the first scenario if you have a zip file for the library there's a way to install it from zip so let me give you a concrete example here so here I am on gith HUB okay and github's this huge code repository all right and what I want to do is get this Morse code Library up here okay and let's just pretend that hey this is not in the Arduino uh ecosystem all right maybe it is I don't know so I just going to click this code button and I'm going to say download the zip file right because you got to have a for this first method you need to have a zip file so I'm going to download this file and it really doesn't matter where you download it as long as you know where you download it so I'm just going to download it to like my downloads right so it's called Morse Master I'll hit save okay so now I have a zip file I'm not going to unzip it I'm going to come over to the Arduino IDE and I'm going to go to sketch include library and then I'm going to say add zip Library I'm going to click on this and it's going to open up a window and it's going to say hey look for this Library so I think I saved that in downloads and uh what did we call that um Morse here it is mors master.zip all right and then I'm just going to click open okay and then it's saying hey I'm processing this it says the library's been installed successfully installed that library now adding a zip file Library using Arduino ide1 is the exact same thing so all you do is go up to sketch include include Library add zip Library same exact process okay hey that was pretty easy right that was a manual install but you know what let's do this let's go to sketch include Library where should we find this that's right we should find it under the contributed libraries right because we had to install this um it's like not doesn't come pre-installed let's see if we can find Morse okay there it is Morse right here if I click that it should include mors all right that's cool well hey let's just double triple check let's see if that folder is in our libraries folder in Arduino Sketchbook so I'm going to go look in there again all right so here I am in my Arduino Sketchbook folder I'm going to come down to libraries all right here's all the libraries and I'm just looking around it was called Morse right so let's oh there it is Morse and what files are in here okay well notice here so we have an examples folder okay and we've got the keywords cool and then we have mor. CPP and Morse Doh those are the actual code files themselves like okay sweet so that's one way to manually install a library here's another way to do it and you don't even use the Arduino ID so check it out so what do you think I might do here I'm curious what do you think I might do in order to put another Library make another contributed Library available H all right so check it out here's another Library it's called timer one okay so here I am again on GitHub and I'm going to go ahead and download this timer one Library let's assume that it's not available in the Arduino IDE all right so I'm going to just go to download zip and I am going to save it right in the Arduino Sketchbook folder all right so I'm in Arduino I'm going to come down to that libraries folder it's in here somewhere right here's libraries okay all right so here we are in the libraries folder and I'll just click save okay so now I have saved this so let's go to that folder now so here I am again I'm in my Sketchbook folder Arduino and I'm in uh looks like I'm in the libraries folder here we are right here here's the libraries folder and what did we just save we saved timer one so I'm going to come and I'm going to look for the um zip file that I here it is right here timer one now it looks like I already have that in here I'm just going to move that puy the trash okay so now what I'm going to do is I'm going to unzip this now I'm I happen to be on a Mac uh so I can just double click this and it'll unzip that for me okay if you're on a PC you right click and you know do like one ZIP something like that okay now once I've unzipped this file I can get rid of that zip so I'm just going to go ahead and move that to the trash here is this folder right here timer one master and when I open this notice we've got uh timer 1. CPP and timer 1. now here's the Deo and this is massively problematic the name of this folder and the name of theh file that you're going to first call need to match okay so notice that this one says timer one-master and this one just says timer 1H well you have to change the name of this so that they match okay so I'm just going to get rid of that I'm going to change it to timer one now they match so I had to like do that manually notice when we use the Arduino ID you didn't have to do that so anyway so I did that now I'm going to come back over to the Arduino ID now before your Arduino IDE will show you that library in the contributed Library you need to close and reopen the Arduino ID so I'll just do that real quick and now when I go to sketch include Library scroll down I should see timer one and there it is sweet okay so there's three ways to install an Arduino library now there's one little trick I want to show you you know we've been installing these libraries and do you remember that examples folder that we saw in several of those libraries check this out if you go up to file examples and you come down here and it says examples from Custom libraries this is where you're going to find those example sketches that were included so before we had Morse right so this this serial example is an example of how to use the Morse library and then what did we do we did timer one look there's three different uh examples here on how to use this timer one Library so that's a really great place to start when you're trying to learn how how to use the code in one of these libraries now if you're really into the Arduino stuff and you want to just accelerate your skills I highly recommend checking out programming electronics.com we have a great training program there but hey while you're here you should check out this video Arduino in 90 minutes it's been viewed almost 2 million times and it's going to really help you fill in some of the ad dos about how to use Arduino
Info
Channel: Programming Electronics Academy
Views: 4,151
Rating: undefined out of 5
Keywords: Arduino, Arduino IDE, Arduino Lesson, Arduino Sketch, Arduino Tutorial, Arduino(Brand), C++, Computer programming, Electronics, Learning Arduino, Microcontrollers, Open Source Hardware Group, Programming Electronics Academy
Id: LXLfA3uRP3w
Channel Id: undefined
Length: 21min 23sec (1283 seconds)
Published: Fri Mar 22 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.