Placeholder Image

字幕列表 影片播放

  • If you're looking for the rest of the videos in this Siri's, please go to Eli the computer guy dot com to see in my full catalogue of videos.

  • Welcome back.

  • So in this video, I want to talk a little bit about what you used to code for your Arduino projects.

  • So whatever you do in, aren't we know Project you're going have some type of art we know board, you're going, have your sensors, you're gonna have your motors at that time of thing, and then you actually have to feed code to your Arduino board.

  • So it knows what it's supposed to do, how it's supposed to interpret, uh, the inputs and then what it's supposed to do for the outputs.

  • So the big thing to remember whenever you're dealing with an Arduino board is that this is simply a microcontroller.

  • It is very important to understand that this is not a full flesh computer.

  • A lot of people get confused, they think aren't we know, and raspberry pi is same same but different that basically they're the exact same thing.

  • It's very important, understand?

  • No other than them being relatively inexpensive, there's a lot of difference between an Arduino and a raspberry pi.

  • A raspberry pi is an actual computer that happens to simply be inexpensive and run on something called an arm processor so you can put an operating system on a raspberry pi.

  • You can do all your normal computer re type stuff on a raspberry pi, and so, if you're going to do something like code for a raspberry pi, you have a whole bunch of options, right?

  • Whatever.

  • A lot of different languages were running a raspberry pi.

  • And so, just like if you're dealing with a normal computer, you will pick the language based off of what you're actually trying to solve for when you're dealing with an Arduino, it is not the same.

  • This is not a full fledged computers, just simply a microcontroller.

  • Basically, what you do is you feed it the environment variables, and then you feed it a loop.

  • So basically, there's a loop that just continuously loops, Um, and then that that that's all it does.

  • You can't install my sequel onto this.

  • You can't install a pathway onto this.

  • This assembly a microcontroller, you feed it instructions.

  • It does whatever those instructions are.

  • So for most people when you're going be coding for Uruguay.

  • No board.

  • You are going to be using what is called the Arduino I e.

  • Now to be clear, and you always have to be a little bit careful.

  • Whenever you talk about technology, there are other ways to code for the artery.

  • No board, but you'll figure that out.

  • Or we'll talk about that when we get to that point.

  • For the most part, especially in the beginning, when you're hobbyist when you're playing around with this stuff, you will simply use the artery.

  • No, I e.

  • Now a lot of people ask what programming language do you use for the art We know and that's again, it's kind of it's kind of one of those fuzzy, fuzzy answers.

  • So basically, when you're coding for the art, you know within the artery No, i e.

  • You're using what are called C or C plus plus of functions.

  • So there are functions that have been created that will turn your instructions into c++ went.

  • So whenever you click on the compile button, basically what happens is the code that you that you've written gets turned into C C plus plus, so how this gets coated to C plus plus the basically what the code that you're right looks a lot like C C plus plus, but it's not really that you're coding and C C plus plus, you're you're writing functions that are then compiled into C C plus.

  • Plus, if that makes any sense, the big thing to understand here if you're starting to get a little bit confused, is you use the artery.

  • No, I d e you create a sketch with in what's called the yard, we No, i d e.

  • You are going to have to write out the code within that I.

  • D.

  • E.

  • That idea is going to compile into C C plus plus, and then that is going to upload the code to the board.

  • So don't get lost too much in the weeds with the whole You know what programming language that you're going to use.

  • That type of thing is just important.

  • Understand?

  • You used the i d to write the code that's gonna get compiled and then showed up to the road.

  • We know once you learned a whole bunch more about how this stuff works, then you can start to get a little bit more fancy.

  • That is one thing to understand whenever you're dealing with the Arduino again anything in the d i y Tech world, there is the simple way to Theo There is reinventing the darn wheel you will as you go As you go, you will learn all kinds of fancy new ways to code for the aren't we?

  • You know, upload code of the aren't we know there's all kinds of stuff that you can D'oh.

  • But in the beginning, in the beginning Ondas long as it works for you Just remember you do the yard.

  • We No, i d e you're right.

  • Your code and what's called a sketch that gets uploaded to the board That will do you for a long time if you want to know more about the different ways to code for a DWI.

  • No, there are other options out there, but it's one of those options that you don't have to worry about this boy.

  • So let's actually go over the computer so I can show you wear toe downloaded the artery?

  • No, I d from on then show you a little bit about the artery.

  • No, I d so that you get comfortable with that environment.

  • So to make life easier on how to find the Arduino i d.

  • E really?

  • The best thing that you should do is go to Google or whatever else and plug in, Aren't we no space I d e and see what the search results are.

  • Basically, what should pop up first is hardly know software i e.

  • It's important that you download the software from Arduino dot cc.

  • So the main website for all we know is not artery no dot com.

  • It's actually hard, we know dot cc.

  • So when you go searching for the Arduino I d e look for whatthe link says.

  • And if the link says Arduino dot c c plus something like software and there that is what you're going to be looking for, then all you do is you.

  • You click on the link and you come here.

  • There is a web editor.

  • We're not gonna talk about that today.

  • What we're going to be dealing with today is actually being able to download the artery.

  • No, I d.

  • And you can see that they've ported the artery.

  • No, I d too many different types of operating systems.

  • So there's Windows versions of the I D it Windows Hap Mac OS X Lennox for the X 86 processors and Lennox for the arm processors.

  • Soem or less.

  • Whatever operating system you're using, they should have an option here for you.

  • And then from that you just click on on this, you download and install it.

  • I've seen many of the different versions of the artery.

  • No, I d e and horseshoes and hand grenades.

  • They all seem to be about the same.

  • So I don't think you'll have, like, a different experience if you were using the Windows version versus whether you're using polemics version.

  • So once you download and install the Arduino I d eat, you could just open it up.

  • So for maybe Windows?

  • Oh, you go to finder your applications and you go, Where would we know is and you just open it up and this is what it's going to look like.

  • Eso these air last projects that I was working with and we can see these are different sketches that I was working on.

  • Now, if we go up here, we take a look at the basic configurations and the settings for the Arduino i d.

  • You go here, we take a look at preferences preferences air Pretty basic.

  • You know what the sketchbook location is going to be?

  • Editor font size.

  • You know, that might be something you want to change.

  • Verified code after upload s O.

  • This is an important thing.

  • So when you're writing the code, you can have the artery.

  • No, i d e automatically verifying for you.

  • So if you don't have this check mark checked, basically what'll happen is your code just simply gets uploaded.

  • And then whatever happens, happens.

  • If you have this checked it will.

  • It will actually verify to make sure that you haven't screwed up the code.

  • So that's an important thing.

  • Check for updates on start up.

  • And there's a few different settings here that you could work with later again.

  • Got some network settings.

  • Uh, then we go from that we go to file.

  • This is the normal thing.

  • We have sketchbook, you know, open new, open, open.

  • Recent sketchbook s.

  • So basically this these are the sketches.

  • So any any time we create this kind of script, So in the yard, we know world a script is called a sketch.

  • So any time we do that and we created here, it will go into our sketch book.

  • The other thing that's kind of cool here is we have examples.

  • So what examples are is, these are sketches that have been created by the art we know folks so that you can simply use them on then and then change them as need be.

  • So there's a basic one here, such as Blink.

  • Basically.

  • You can open this up, and so this sketch here blink allows you to make an led light blink on your Arduino board.

  • And so one of the nice things is, if you're doing something where it's kind of been done before you like a blinking led light on a board, you can go.

  • You can open up the example.

  • You can tweak it as you need it to be tweet on.

  • Then you can simply use that code.

  • From there, you go over to the edit.

  • There are some interesting options here, such as copy for forum or copy as HTML.

  • Now let's say you're having problems with your your sketch again, especially if it's a longer sketch.

  • Not not a short one like we're doing most of these projects.

  • Let's say something longer and you actually need help with it.

  • Well, if you try to simply copy and paste code from your sketch toe a website or to a forum, most likely it will fail out because there are security precautions.

  • Basically, there's there's validations within most websites, so that code cannot be directly inputted into that website.

  • So if you do a copy as HTML or copy for Forum, this adds all the HTML tags in that type of thing to make it eight email text so that you could actually post it into something like a forum.

  • And it won't fail with a validation.

  • So those are some things to think about.

  • Comment a nun comment Increase in Dent.

  • You know, increased font size so on and so forth we can go over to sketch.

  • So sketch has this verify and compile.

  • So this what What you can use this for is if you don't necessarily want to upload the sketch to your board right at this moment in time.

  • But you just want to verify that there is no glaring problems with your code.

  • Basically, you could just click on this, verify and compile and it will go through and it will verify your code and compile it to make sure that it will actually function.

  • This is important.

  • So if you're like me and you do stupid things like forgetting Semi Coghlan's or you put semi colons where semi colons aren't supposed to be or you forget a bracket or something like that simply got going up here to sketch to verify and compile, it'll go through and it will show you those problems before you actually try to upload it to the board.

  • You can do the upload here, there, and then there are some some other things here with export compiled binary wth.

  • The other thing is, there's something called libraries, so we haven't dealt with this yet, But when you're dealing with things such as servos, when you're dealing with things such as network shields, basically what libraries are his libraries are all the code that allows those particular things to function right.

  • So basically what you can do is you can add to the library to your code, and then the Arduino i d.

  • E essentially ads all the code to make that device work within your project without actually having to to write it into the script yourself, eh?

  • So you've got all kinds of different our libraries here, GS and mouse Robot control Robot.

  • I are so on and so forth and you click here you go to manage libraries.

  • And so with manage libraries, you can actually install new libraries.

  • So if there's a library that's not installed with you in your I d e, that's one of the things that you can do.

  • There s oh, that's some of the important things we're looking at when you're looking at this little sketch menu, then you go to tools.

  • Uh, you know, there's a few tools here that a useful auto format again.

  • So if you're like me, I don't really like Cody.

  • And again, whether it's whether it's spaces or tabs or anything else.

  • Whatever I write code, it looks horrible.

  • The cool part about auto format is it basically auto formats for you, right?

  • So if I'm here and I have, you know, this and it looks like this, I go here to tools auto format.

  • Whoa.

  • So, again, auto format.

  • If you're doing this for any type of class.

  • Whether it's a high school class or college class, I highly recommend you use on a foreman because the thing is, when you verify and compile, it won't do that auto format for you.

  • It will simply go through and verify that the code will work the auto format.

  • What that does is goes through and make sure the code is basically human readable s.

  • So that's a valuable thing.

  • Go here to manage libraries again.

  • A different way to be able to upload libraries and such to the Arduino i d e.

  • We'll talk about that later.

  • Something called the serial monitor S so we'll use a serial monitor in many projects.

  • This is how you can actually read information from the Arduino.

  • So let's say we're doing a temperature project, so we put it an analog temperature sensor into the Arduino.

  • And then we would simply want to read what temperature that sensor is telling us.

  • So we can start the serial monitor and actually be able to read that temperature directly from the Arduino board.

  • The serial plotter.

  • This is kind of cool.

  • So the serial monitor this just writes everything else.

  • You tell it what?

  • What you wanted to write?

  • You say, You know, temperature in Celsius is and then you put the value of the variable.

  • That's a temp See on.

  • And then we'll just print that out.

  • Normal text.

  • What's cool about the serial monitor is this will actually print out a cz a chart.

  • So as the temperature goes up, the chart will go up, and as the temperature goes down, the chart will go down, eh?

  • So that could be a valuable thing.

  • If you're looking at things like temperature, you're looking at things like humidity, where you want more of a visual representation.

  • You just want to see it go up and down.

  • The cereal plotter could be useful.

  • Then we go down here and we take a look at the board.

  • So again, it's important.

  • Understand?

  • There are many, many, many different.

  • Do we know boards out there?

  • Uh, the, you know, is basically the standard one we use for many of our projects.

  • We've got the Leonardo land order with Internet, many Arduino after net Wi Fi oh, lots of different things.

  • And so when the important things to understand is that in order to be a upload your sketch to your board.

  • Here, you have to select the appropriate board that you're using.

  • If you selected the wrong board, it will fail.

  • When you try to upload it.

  • The next thing to go to is the pork again.

  • This this this can cause a lot of problems to people.

  • So this is the port that you're connecting your Arduino too.

  • So if an Arduino is plugged in using USB, you'll actually see a USB port here.

  • And so you get simply have to click on that USB port to verify that it's trying to communicate over that poor.

  • This could be a big thing, especially with the Arduino projects.

  • When your hump you're unplugging the artery.

  • No, you're plugging it back in your unplugging the art.

  • We know you're plugging it back in.

  • Sometimes the port will get confused.

  • And so when you go to upload, it will fail simply because it doesn't know what pork to be able to send the information to.

  • You just go to poor, and then if you're connected, as I said to us be, you would just click on the USB.

  • The next thing you can do is you go here to get bored info.

  • So if a board is plugged in, you can click on that.

  • And then from there you can see what bored you're plugged into again.

  • Is that a new no board, or is it some kind of nano board or something like that?

  • You can get that information from the board, and then you can go up here.

  • Toto Thio, select what you need on.

  • So those were some of the basic stuff with the yard.

  • We know again, if you go to file, you know, thing is, you can say you can save as you can print do the whole nine yards.

  • Then if you go down here, you can take a look at what a sketch looks like.

  • We'll talk a little bit more about sketches in a different video, but essentially here thes air, the three components of a sketch.

  • So in the very beginning, what we're doing is we're defining the pens.

  • So the pins on the Arduino board we're saying essentially what to call those pins.

  • So in this particular sketch, we're saying pin a zero should be called Sensor pen were saying pen digital Nagy, we call Green led were saying Pen Digital 10 should be called Red Led.

  • We then set up the environment so we actually set up the environment that that the sketch is going to run in, and here we say pin mode green led to output.

  • Since their digital pens, we can set them so that electricity will go out.

  • So basically, what this is gonna be used for is to turn on this green led Penn mode red led outputs.

  • We're setting the outputs.

  • You can set it to either input or output for digital pins.

  • And then that serial monitor that we talked about cereal duck begin at 9600.

  • We're starting that ability on the board so that we could go to serial monger and actually be able to read from it.

  • Then we go down to the loop and this loop here, this is the loop that keeps running, running, running, running, running, running, running, running, running.

  • Uh, basically, until you you pull a power.

  • I won't go into this again.

  • This is a little stick in order to read from a temperature sensor, but it goes through, reads from the temperature sensor turns on tthe e red led or turns on the green led and then a delays for three seconds, and then it loops and then loops and loops, and then it loops and then loops.

  • So this is a basic overview of the art.

  • We No, I d e.

  • It's it's really, really easy to use.

  • It's one of those things, you know, just just work on a few projects, and by the end of a few projects, you'll know how to troubleshoot any minor problems.

  • And he should be fine.

  • So that was a basic overview of the Arduino iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.

  • It's a relatively simple idea.

  • Use the big thing with the I D.

  • I.

  • D is just don't over think it again.

  • A lot of people get confused on, and they don't realize that the Arduino is not the raspberry pi.

  • I think I think that's something like when people hear about aren't we know people learn about are we know normally about the same time they learn about the raspberry pi.

  • They're both rather small.

  • They're both rather an expensive.

  • They're both used for i o T i o E projects.

  • And so in people's minds, they think, oh, raspberry pi, same same.

  • But different than the Arduino?

  • Uh, no, that's incorrect.

  • It's different.

  • Different but different.

  • They're entirely different things.

  • They're just they're not.

  • They're literally not.

  • The same thing is like saying a refrigerator and an oven are same.

  • Same a difference.

  • Well, they're both appliances, but you know, you don't want to be putting your ice cream into the oven doing something really weird with it right on.

  • So that's a thing is basically with the Arduino.

  • I.

  • D.

  • E is just very simple to use.

  • There's not a whole hell of a lot to it again.

  • A lot of people try to overcomplicate this in their mind, because again, there are other ways to code for the urn.

  • We know there's.

  • There are other ways to upload a sketches to the yard.

  • We know, but that that's for when you get to that point.

  • Those are more complicated ways of doing things.

  • There are reasons that you would you would up right code and upload code in a different fashion, but that's that's That's when things get a lot more complicated.

  • That point you're not generally simply turning on and off led through that type of thing you're trying to do something more complicated and therefore that that's why you need to go through those soups as a beginning person at this point in time.

  • Because because Google search artery no i d e a go.

  • Nor do we know dot cc download and started installing i d e.

  • On, then getting go from there and learn he should be fine.

  • One of the troubleshooting things that I will tell you there's there's a couple of troubleshooting things with the artery.

  • No, I d.

  • You might run into problems with again.

  • Make sure the port Make sure your report is actually connected, especially if you have a different USB ports.

  • If you're plugging the yard, we know in and you're unplugging the Arduino.

  • Ah, lot of times the idea, you will simply get confused.

  • You simply go to the poor.

  • Select the USB port that you're using.

  • You should be fine.

  • Make sure the right board again a Leonardo is not the same as in, you know, bored.

  • So if you write code, you know you write code.

  • Basically, the code that you're going to write for either of these boards is more or less the same more or less the same code running here That'll run on here.

  • But if you don't go and change the board, you may run into a problem.

  • So you write code you've been using a Leonardo, you forget to change the board in the I.

  • D.

  • You try to upload to a new No, and it will fail out.

  • All you do is you go in there and find the right board.

  • One of warnings that it will give you is make sure you truly find the right board suck as versions numbers.

  • So I have an Arduino, you know, with WiFi so you can actually get an Arduino, you know, with WiFi built in.

  • Curious thing.

  • They're currently up to version number two, but they did have a version number one.

  • One of the trouble suit issues Iran into is I selected.

  • Was it, you know, with WiFi I kept trying to upload to the board, and it kept failing.

  • The reason was I had simply visually mist where there was, you know, WiFi, you know, version, too.

  • And once I clicked on that, everything worked great.

  • For whatever reason version, you know, you have to actually slept.

  • The version two versus the original version, you can run into a problem that way.

  • Another issue that I have seen it is a little bit of a quirky issue.

  • Just keep in mind all computers get a little bit.

  • Quirky is I have a scene where sketches will not upload simply because the artery No, I d e literally does not like that sketch.

  • So I was doing a meet up.

  • I was teaching everybody, you know, how how to do a very small project.

  • One of the people in the class it was refusing to upload.

  • We went through.

  • We did all the trouble shooting.

  • We're trying to figure it out.

  • We're going to this whole mess and for whatever reason, it just refused to compile it.

  • Refused upload as a last trouble shooting technique.

  • I told the guy, just copy and paste all the code, opened a new sketch, dump it into the new sketch and then try to upload it and everything worked out.

  • I don't.

  • So if for some reason you look at your sketch, everything looks fine, everything seems like it should be okay.

  • Do you realize there, man, It's all computers.

  • There may be a little bit of work.

  • There s so few copy.

  • Copy all your code.

  • Paste it into a new sketch.

  • Try to upload it.

  • That may may solve your problem for you again.

  • Little little things you'll learn as you go.

  • But in the beginning, that could be a little bit frustrating.

  • But no big deal.

  • As always, I enjoy doing this video and look for this.

  • You know, the next video.

  • Please go to the line, the computer guy dot com and failed normal dot com to see the videos that are too dangerous for YouTube.

If you're looking for the rest of the videos in this Siri's, please go to Eli the computer guy dot com to see in my full catalogue of videos.

字幕與單字

單字即點即查 點擊單字可以查詢單字解釋

B1 中級

Arduino IDE介紹 (Arduino IDE Introduction)

  • 11 0
    林宜悉 發佈於 2021 年 01 月 14 日
影片單字