Man and two boys holding a super-sized Arduino Uno

Arduino Tutorial: Beginners Start Here!

This Arduino tutorial is a crash course for complete beginners who want to get started programming the Arduino Uno. 

You will learn:

What an Arduino is

How to program an Arduino

How to connect an Arduino to your computer

This Arduino tutorial will walk you through a basic example Arduino project, which makes an LED on the Arduino blink.

Along the way, we’ll also tell you a little bit about coding and computer programming languages

You can check out our Arduino tutorial video here and subscribe to our YouTube channel to keep up with new projects.

Everything is explained below as well.

Supplies

Arduino Uno

Power supply (to run the Arduino when not connected to your computer)

USB printer cable (either an A to B cable or a C to B cable, depending on whether your computer has USB A or C jacks)

What an Arduino is

This is an Arduino:

Arduino Uno board

An Arduino is a little computer that we can use to control other electronics parts. 

We can use it with different kinds of sensors to measure things like temperature and light. 

And we can use it to control other electronic parts like motors and LEDs.

The image above is just one type of Arduino board– it’s called the “Arduino Uno.”

The Arduino Uno is a good choice for beginners. It’s very popular and there’s lots of information online to help get you started with this board.

And here’s a fun fact: if you’re wondering why it has a foreign-sounding name, it’s because the Arduino was invented in Italy.

How to Program an Arduino

We give the Arduino instructions using Arduino language. The Arduino language is a computer programming language similar to others you may have heard of, like Java or Python. 

To write an Arduino program on your computer, the first step is to download the Arduino IDE (Integrated Development Environment) on your MAC, PC, or Linux machine.

Downloading the Arduino IDE

The Arduino IDE is available to download for free on the Arduino website for PCs, Macs, and Linux machines.

Writing an Arduino Sketch

After you download and install the software, you can fire up the Arduino program on your computer.

The first thing you see is this window that pops up called “sketch.

"Sketch" window with setup and loop functions

Here, a “sketch” is an Arduino program, and what you see is Arduino language.

A function is just a part of a computer program that does a specific task.

The two basic Arduino functions are “setup” and “loop.”

The “setup()” Function

This line starts with “void”, which means that this function, “setup()” doesn’t report back any information after it runs. 

Arduino sketch with setup() function identified in a red box

The two slashes next to each other are for a line of comments. You see the following says, “put your setup code here, to run once:” 

Arduino sketch with 2 forward slashes indicating a row of comments indicated by a red box

Since the slashes are at the beginning of the line, the Arduino will ignore those words when it runs a program. 

And, just like the comment says, anything you include in the setup() function will only run once when you upload your code to the Arduino.

That’s half of a simple Arduino sketch. The other half is the loop function

The “loop()” Function

After the curly bracket closing the setup() function, you can see the  “loop()” function. 

Arduino sketch with loop function indicated by a red box

Again, this function runs without reporting back information, so we see the “void” data type. 

The parentheses show that this is another function. 

The 2 slashes start the line of comments saying, “put your main code here, to run repeatedly.” 

The curly brackets enclose the instructions you want to repeat over and over.

Running the “Blink” Example Project

The Arduino comes with some example projects, which makes it easy for beginners to get started.

If we go to File, Examples, Basics– we see the example sketch “Blink.” 

Path to Blink example project is File-Examples-Basics-Blink

The first part of this sketch includes a long comment.

Instead of using the two slashes at the beginning of each line, they use the star and slash together. This identifies a block of comment text on multiple lines.

Here is the beginning symbols for this block of comments:

Red box identifying "/*" as the beginning of a long comment spanning multiple lines.

And the comment tells us that we can control a built-in LED light named LED_BUILTIN. 

Inside the setup() function we see another comment explaining that the next bit of code is to initialize the LED_BUILTIN pin as an output, which will allow us to send enough electrical current to light up the LED.

Comment specifying code that will initialize LED_BUILTIN as an output

 If we just wanted to detect electrical signals from a pin, we would leave it initialized it as an “input” instead of an output, which is the default pin state.

Let’s take a look at what it says in the “loop()” function

Loop function in Blink sketch

Here we see the “digitalWrite()” function, which specifies that the LED_BUILTIN pin gets set to “high.” 

That sends 5 volts to that pin, which will turn on the LED. 

The “delay()” function instructs the Arduino to wait before the next digitalWrite(), which sets the LED_BUILTIN pin to “low”, and turns off the LED.

How to Connect an Arduino to Your Computer

To connect the Arduino to your computer, we use a USB printer cable. The official description is  a “USB A to B male/male type cable.”

Under the “Tools” menu, we can go down to Board and make sure that we set it to the correct type of Arduino board– in our case, an Arduino Uno. 

Path to choose Arduino board is Tools-Board:"Arduino/Genuino Uno"-Arduino/Genuino Uno

The last step is to specify the serial port that the computer will talk to in order to communicate with the Arduino. 

Under “Tools”, select “Port” and the appropriate port that looks like this:

To run the program, we just have to click the “upload” button, which is a little arrow pointing to the right (shown in the red box above).

Congrats! You’ve completed this Arduino tutorial and the LED on your Arduino Uno should now be blinking.

Do you know how to change how long the LED stays on and off?

You can change the numbers in the parentheses of the “delay()” functions. Every time you change the sketch, you’ll need to upload it again to the Arduino.

If you enjoyed this Arduino tutorial or have questions, please let us know.

Are there other projects you’d like us to build? Please leave us a comment!

Check out all of our cool engineering projects.

Or, narrow in on our simplest basic electrical circuit projects or our slightly more advanced electrical engineering projects. 

We also have a helpful basic electronics page that teaches skills such as how to use a breadboard and multimeter.

Don’t forget to sign up for our free monthly newsletter to receive Geek Pack Hack updates along with an even wackier simple circuit project. Have fun!

Leave a Reply

You have to agree to the comment policy.


The maximum upload file size: 128 MB.
You can upload: image.