Check out a free preview of the full Hardware with Arduino & JavaScript course
The "Getting Started with Arduino" Lesson is part of the full, Hardware with Arduino & JavaScript course featured in this preview video. Here's what you'd learn in this lesson:
Steve tests the Arduino board with a "hello world" example. The Arduino is connected to the computer, and an example blink program is loaded, causing an LED to blink on and off.
Transcript from the "Getting Started with Arduino" Lesson
[00:00:00]
>> So let's kinda do, like I said, the Hello World of an Arduino also known as does my piece of hardware work is getting an LED to blink on it. So we'll do that for a second to kinda make sure everything is up and running, and we'll do that the very first in the actual Arduino tool.
[00:00:20]
So, here we've got the Arduino IDE. If you ever use processing, which is a tool for making art, based on Java, it should look very familiar and similar to you. Like I said, it is C++, but an abstraction on top of it. You do have kind of two main methods that get called, which is setup and loop.
[00:00:40]
Setup does what you think it does, and then loop begins to run once the Arduino is loaded up. The other thing you can do is you should see the, I will tell you only because I have a stack of boards that it's usually more helpful to have it plugged in before you start up the IDE.
[00:00:59]
So if you do not see your Arduino Uno that you plugged in after you opened the IDE, just do the way that you fix everything with technology. Quit it, and open it back up, right? When in doubt, let's just get this out of the way. Now, when in doubt, turn it off and turn it back on, right?
[00:01:18]
But in this case, I would just quit the app and reopen it. It might be there, it might not. As you can see, I've also got my Bluetooth incoming port and a guitar pedal that I used one time. So now I've switched it to the Arduino Uno. And one of the other things that I will kind of point out now, is that this menu kind of changes based on what board you have plugged in.
[00:01:45]
But you will see these examples where for the starter kit, there are a bunch of prewritten code already there. So if you wanna practice, if there is something in the starter kit that you see, that you just want to wire up and have the code written for you.
[00:02:04]
That is an option. Those are all here, but if you don't see it, it is because you do not have the Arduino Uno selected in that drop-down. This list of examples will change based on what board you have plugged in. And there's a whole bunch of other different examples that you can kinda take a look at.
[00:02:23]
For us right now, we want to go into Basics and Blink. All this does, and we can look at this code real quick and if the C++ hurts your feelings, that's okay, it hurts my feelings, too. But we'll kinda switch over to JavaScript in a little bit, but I think it makes sense to kinda look at the basics of how everything is laid out in this case.
[00:02:49]
So there is one LED that is kind of like built in, it's a tiny little one. You will see it when it blinks, how about that? If you don't see it immediately, and that one is by definition, stored for you in a variable called LED_BUILT_IN, which is good name.
[00:03:14]
And that is also a euphemism for PIN 13, which you will also see on your board. And when I switch over to that camera will kind of like take a tour of the board, I'll pick it up and move it around and show you different pieces of it.
[00:03:28]
But trust me right now that the built in LED, and whatever we plug into PIN 13 are roughly the same thing. And that is the setup piece where we just kind of like, okay, this is gonna be an output pin cuz sometimes you want data coming into the Arduino board.
[00:03:43]
Sometimes you're saying, no, I'm gonna tell something in the outside world that things are happening, right? And so you just kinda specifying that out in the very beginning and setting that up. And then we move into the loop which will run as a comment very eloquently says over and over again for ever, or until you turn it off or unplugged the board.
[00:04:05]
Forever is yeah, a relative term to which we do a digital write of high and then we wait a second, and then we do a digital write of low. So turn it off, turn it on. Send it 5 volts, don't send it 5 volts. Send it 5 volts, don't send it 5 volts.
[00:04:23]
And we run that forever. So in our Hello World here, let's go ahead and we're gonna hit this button here to upload the sketch. Done uploading. So here we've got our Arduino. As you can see, I've got a little LED that is blinking on and it's blinking off.
[00:04:43]
It's blinking on, it's blinking off. The nice thing about anything you use the Arduino IDE for is that actual code is loaded onto the device itself. Now, depending on which device you use, I think the R3 has about 32 kilobytes of memory. There's not a lot of room to do a lot of stuff, which is why it cannot fit all of Node.js on it.
[00:05:04]
There are projects that try to trim down node until it's smallest possible format, but I think even those are a little too big for an Arduino, but like I said it all applies either way. And so I've got this little built-in LED that's going on, that's going off, and if I unplug this and I plug it back in.
[00:05:22]
If I just unplug it and like just take this power adapter over here or a 9-volt battery and hook that up, it will still blink on and off cuz that is the effectively the firmware that's running on it at this moment. With that, if we look on our digital pins they are all labeled, right?
[00:05:39]
So in this case we've got 0, all the way up to 13, those are the ones we mostly care about today with a ground as well. There is a little squiggle line next to some of those, that squiggle line is important. I'll explain what pulse width modulation is later, and then we'll talk about why the squiggles are important then.
[00:05:59]
And then, if we flip it over, we've got our analog ports, right? And these are just for actual more traditional, how much voltage is coming back into this? As well we've also got a 5 volt, and a 3.3 volt, and some more ground over here as well. And those are kinda the ones that we are most concerned about today, right?
[00:06:22]
And so we've got a blinking LED at this point, and so we know, if you see that, means that everything is at least hooked up and wired up correctly
Learn Straight from the Experts Who Shape the Modern Web
- In-depth Courses
- Industry Leading Experts
- Learning Paths
- Live Interactive Workshops