Arduino Tutorial 1: Setting Up and Programming the Arduino for Absolute Beginners

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys this is polemic order from top tech boy comm and I am here today with the all-new the improved Arduino tutorials now those of you who are familiar with my channel know that I have a very very popular series of lessons on the Arduino that I made several years ago and a lot of people have watched him a lot of people have really loved them but it is time to redo those videos because a lot has changed the first thing that has changed a lot of the hardware is changed there's more sensors there's all types of more things that we can do with the Arduino due to the new hardware second thing is there's been some changes in the software and so we really need to redo things with the newer in a integrated development environment the third thing is that I have an improved studio and so some of the production quality was pretty low I think the content in the first series of lessons was really good but the production quality was pretty low and so I've got better production quality right now so it's really time to meet remake the videos but probably the most important changes is that if you remember in the first set of videos I would drink hot coffee from this cup for this series of lessons I will be drinking iced coffee from this big mug so I need you to go pour yourself a nice big mug of iced coffee and get ready to follow along if you're new to Arduino before we get to the end of this video you're going to have not only written your first program you're gonna have written your first four programs and then I'm going to give you some simple assignments of things to do on your own based on what you learn today but today you will get in and you will write your first set of programs now if your if you were here before the first 4 or 5 lessons are going to be repeat you can just kind of skip to the more advanced things but I want to start all the way back at the beginning so we can take a person off the street who knows absolutely nothing and we can teach them to program a microcontroller step 1 you need to get your hardware this series of lessons I will be using this super starter kit you know our three project by E Lego available at the convenient link below in the description hook a brother up get your kid from there this kit cost $35 it includes an Arduino and then just a boatload of components this kit is going to keep us busy for a long time because it's got sensors it's got actuators it's got circular elements it's got everything you need to do hundreds of projects so bargain at $35 step one order your Arduino kit if you already have an Arduino you can go ahead and start playing along right off the bat okay so get your kit ordered step number two we have to install the software and that's that's what I'm going to show you how to do today and the simplest thing is we can go to a google browser I can make myself smaller to get out of your way and then what we just want to search on is arduino AR DUI in o download ok boom first result is the website WWE no CC / ian / main / software we will go there and this is where we download the most excellent and free software I am running on Windows 10 and I will download the latest version of the software as of the time I'm making this video the latest version is arduino one point 8.9 you don't have to download this exact copy this exact version just download whenever you do whatever the latest version is so whatever it says here that's fine there'll be little tweaks but what I'm showing you here should work for a long long long time now I'm on Windows 10 so I'm gonna click on this link which says Windows installer for Windows XP and up if you're on Windows 10 this is what you would click or if you're on Windows XP or higher this is where you will click so we will click there what they are asking you to do is hook a brother up and make a donation I have helped out already and so I'm going to just say just download so I click and then down here if you're in Chrome in the lower left you can see the little exe installer is downloading happening pretty quickly so we will just wait for it it has downloaded so now we just click on that downloaded file if you're not on Google Chrome then you've got to kind of go hunt around and find where that file was downloaded to but on Chrome we just click on it it is asking me are you sure you want to let Arduino change your computer well yes I will click yes and now it's saying do I agree with the Terms of Service yes I agree I'm going to do a pretty standard installation so I'll just leave it with everything check there and click Next it's going to put it put it in a pretty standard location under Program Files slash Arduino and then we click install I'm not going to pause the video because if you're playing along at home you can just download it right along with me I will enjoy a little coffee though it is going pretty quickly here and we're gonna get this downloaded we're gonna get connected to the Arduino and you are gonna write your first program I think you're gonna find it's a whole lot easier than what you think and you're gonna be wondering why have I waited so long to learn to program why have I learnt waited so long to learn a little engineering little computer science well at least you're doing it now ok happy the happy little blue bar is almost all the way across it says completed so now I will click close alright now the software has been installed so if I come down to little search bar or I guess on Windows 7 you could just click the button but I'm gonna say are do we know and there is the arduino app the happy little arduino app and i am going to that you just ignore what i'm doing here for a second okay i'm just gonna put it on my put it on my taskbar ok so here we go trying to get it yeah pin it to the taskbar in that way it'll be down here and be ready to roll when you need it but I can just click it from here this time and you see it is starting to open okay I'm going to switch over to a slightly different view here so that you will be able to see my code in my Arduino okay this Arduino is an Arduino that I just had laying around so I'm gonna unplug it and I'm gonna get out of my super starter kit I'm going to open it up with the little orange tabs and then what you will see is you will see right here on top top is a little envelope a little static envelope that has your Arduino in it so let's get that out and then you will need a USB cable which I already have here the other end of the USB cable is hooked to your PC the PC that you just installed the code on and then we have the Arduino so I will come over here and I will plug the Arduino in and what I hope is when I plug it in I hope that I hear a happy little noise okay I hear the happy little noise and what's that what that means is the PC is recognizing something that it understands has been plugged into the USB and so that means that things should really work from this point okay so now you have arduino ide open you have the arduino plugged in and so you need to call up a program called bare minimum because bare minimis is where you always start when you're writing a program so it has things that you will use in every program that you write so we will come to file we will come to examples we will come to basic we will come to bare minimum okay now you get this program this program shows you the two things that are part of every Arduino program the first is called the void setup the void setup begins with the open curly and it ends with the closed curly the commands that you put in void setup will be executed one time so you set the Arduino up in the void setup then the things that you want to run over and over those commands you put in the void loop the void loop starts with the open curly and ends with the closed curly B every Arduino program has a void setup every Arduino program has a void loop so this is what you're going to start with now the next thing is we have to make sure that we are talking to the Arduino from the IDE so we need to come up under tools and we need to come down to port and we can see that on mine it sees a com1 that might be the mouse or the keyboard or something but then it sees connected to comm 3 the Arduino or genuine Oh uno so it's season uno connected to that port now for you it's probably not going to be port 3 it could be port 7 or it could be port 25 but the point is that it should be the one that recognizes that an Arduino is connected to it now let's just verify that that's true so you see comm 3 is Arduino Uno ok I'm going to come over here and I'm gonna unplug the Arduino right it's been unplugged now if I come to tools and I come to port com1 but doesn't see the Arduino why because we unplugged it ok things are working the way they should so we plug it back in we get the happy little USB noise and you can see some lights coming on on the Arduino seeing that it is in fact powering up and now if we come back to tools and we go to port we can see that the comm 3 is there now you need to go across and you need to select whatever comm port has the Arduino connected to it for me it's port 3 so we select that now we're connected to it alright the other thing that you need to do in your setup you need to make sure that on your board it matches the board that you're that you're using we're using the uno so we come down to Arduino Uno if you are using a nano you would come here or all the different Arduino let's just make sure that you select the board that you're using because if you don't you can have problems so we were on the Arduino Uno ladies and gentlemen we are ready to write our first program and it is as simple as this all right on this Arduino we want to do things without having to start building things so let's just write the simplest program possible do you see these pins along the edge of the Arduino it goes from pin zero they're labeled digital pins from pin zero to pin 13 these pins we can interact with we can send signals to the pins or we can pull signals off of the pins okay and so you can connect things up to these pins and then you can make the magic happen okay but I don't want to build circuits in this first lesson so the most excellent thing is if you look here and see this pin 13 that pin 13 is already hooked up to this little LED on the board so any signal that we send to pin 13 we are going to be sending to that little LED and so that allows us to write our first program without having to wire anything up or hook anything so first thing we got to do is we got to set the Arduino up what pins are we going to be working with we are going to be working with pin 13 so we have to tell Arduino we are working with 10 13 we do that in the in the void setup and we do that with a pin mode Pyaar in capital M OD e pin mode you notice when I type in pin mode with the right capitalization it turns orange that's a happy thing that means that it recognizes the command so I'm going to tell it what I'm gonna do in my pin mode command open parenthesis now I have to put two parameters in the first parameter is which pin are you working with hmm which pen are we working with in 13 ha then we put a comma and now we're going to have to give the second parameter the second parameter is we're telling the Arduino are we going to use pin 13 as an input or an output well we're going to send a signal to it so it is an output kind of like the printer right you send a document to the printer the printer is an output device we're gonna send a signal to pin 13 so pin 13 becomes an output all-caps Oh UT P UT ah when I type it incorrectly what does it do it turns blue that's a happy little blue saying that it recognizes that parameter we now close our parentheses and almost all commands in arduino end with the semicolon we have now given our first command we're gonna execute it one time because it's in the void setup it's just gonna be telling arduino hey we're working with pin 13 it's gonna be an output all right so this is set up for the first program now let's go down to the void loop ha we're connected to that LED what would be neat if we did to that LED turn it on we want to turn the LED on so how would we turn the LED on where we've got to send a signal and the command is digit toll right again case is important digital is all lowercase the first letter of the next word W is capitalized so digital right this is called bumpy font where the first letter of the words are capitalized because you don't want to use spaces and so you can kind of read it better digital write but notice that if I did it wrong digital write and capitalized wrong we don't get the happy little orange color so if it doesn't light up you know you've done something wrong ah I didn't capitalize the dub u WR ite okay we have to give it again two parameters we've got to open hmm what pen are we gonna write to that's the first parameter pin 13 and then second do we want to turn it on or do we want to turn it off well we want to turn the LED on so the command that we would give the parameter we would use is high we're gonna set it high means 5 volts we're gonna set pin 13 to 5 volts so I type in hig H all caps when I do it in all caps its happy it turns blue if you do this you see no happy no blue so you've got to get your case right hi what do we do at the end of almost every command in Arduino the semicolon okay so what does this do in the void setup it tells the Arduino that we will be using pin 13 it's going to be an output and then in the loop we say hey take pin 13 turn it high that should turn the LED on now right now this program is here in your PC we now want to send it down through the USB cable down into the Arduino and you do that with this little arrow here this little right arrow you're gonna click on that and then it's going to send your code down into your Arduino so when I click on that I look here and I get a happy little green bar meaning that it's recognizing the commands it's compiling it and when that green bar goes away it means the program is down in the Arduino and look what happened here on the Arduino boom the LED turned on you have written your first program and you have controlled an item you have turned an LED on mm-hmm maybe we should write a second program what should the second program do mmm turn the LED off I want you to guess if I turned it on what do you think would turn it off no L Oh W all uppercase so now how do we download the program into the Arduino we come up to this little right arrow we click on the right arrow boom it goes down and what happens the LED was turned off you have written your second program you can turn the LED on you can turn the LED off well if you hooked other things up to pin 13 already today you could be turning them on and off and so even though this is really simple it's very very powerful now I want you to think let's turn it back on so I'm gonna go back hi okay hi download it in the LED is on okay if I can turn the LED on and I can turn the LED off what could I do in program 3 I can make it blink how would you make it blink well you digitalwrite 13 hi and then you have a new command digit told digit all right what pen are we working with 13 and now we can want to make it go low so we're gonna turn it on and off and then it should blink so we come up we download the program and it goes ooh wait a minute it's not blinking no blinky okay hmm what could be wrong all right think about this does a computer do things quickly or does the computer do things slowly it does it quickly very quickly so what are you doing with this program that you just wrote you're turning it so quickly your eye cannot perceive that it's blinking it just looks like it's kind of dim okay and so the problem is you're blinking it so fast that you can't see it so you need a new command what command do you need you need to be able to put a delay in your program where you turn the LED on you delay you turn the LED off you delay so let's add another command after the turn it on what do we want to do we want to delay the command is wait for it delay you spell it right you get the happy orange open promote open parenthesis we got to give it one parameter and that's how many milliseconds you want to delight okay there's a thousand milliseconds in a second so if we want to leave it on for one second that would be how many milliseconds 1000 milliseconds is one second don't forget the semicolon II okay so we turn it on we wait a thousand we turn it off and what should we do wait a thousand so what this is what is this going to do turn the LED on for a second turn it off wait a second turn it on wait a second turn it off wait a second so it should be a pretty slow blink here how do we get this most excellent program down into the Arduino we click the right arrow we watch our little LED and look at that off on on it's blinking exactly like we told it to okay now do we have to blink balance like that no let's leave it on for a tenth of a second and then let's leave it off for nine tenths of a second so the duty cycle is going to be one second but this the LED is going to be on for a tenth and off for a 9/10 what would a tenth of a second be well a thousand milliseconds is one second so a tenth of a second would be a thousand divided by 10 which is a hundred and then we want it to be off for nine hundred so still it's good the duty cycle is going to be one second but it's going to be oh no ha ha ha like that ok so let's download it and let's see what happens uh uh ok let's do it the other way let's have it mostly on 900 on 100 ah let's download that so this is gonna be uh on off on off you see it's mainly on it's mainly on I might have messed that up a little bit but I'm sorry right so hopefully yours is hopefully yours is doing that man you've written your first three programs and it's just your first lesson and you've already written three programs okay let me give you a couple of assignments I want you to first of all what I want you to do is I want you to write a program where it will blink fast and I want you to see how quickly you can make it blink where your eye still perceives that it's blinking okay so let's say let's say if I put 500 and 500 that's a half a second on and a half a second off all right and then if I look at it I can clearly see that that's blinking but as you make that number smaller and smaller you're gonna reach a point that your eye cannot perceive that it's blinking and it's just gonna look like a constant maybe somewhat dim LED so what I want you to do is I want you to do that experiment and see how low you can make this number how fast you can make it blink you've got to change both of them and still perceive that it's blinking and then put your results down in the comments and let's see if you guys are getting similar answers as far as your eye perceiving that the thing is blinking versus it just looks like it's it's constant okay guys this is public order from Coptic boy comm if you like this video give us a thumbs up think about subscribing to the channel maybe sharing it with people if you haven't already get your kit and follow along with me leave your comments down below really love to hear from you guys love to get your comments and your feedback so hopefully you will do that this is Palmer quarter from top tech boy comm I will talk to you guys later
Info
Channel: Paul McWhorter
Views: 828,040
Rating: 4.9618449 out of 5
Keywords: Arduino, Tutorial, Lessons, STEM, Getting Started.
Id: fJWR7dBuc18
Channel Id: undefined
Length: 23min 50sec (1430 seconds)
Published: Fri May 31 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.