This beginner Arduino tutorial “How to program Arduino Nano” is for those who doesn’t have any electronic experience whatsoever!
Look at the picture below and see what I have to start with: a breadboard, a LED (a yellow one), a resister, mini USB cable, and a microcontroller.
Let’s have a look at the breadboard. Basically, the only thing you need to do is to push the components into the existing holes. Next to it is a microcontroller (by the way, they are surprisingly cheap, a few dollars). Microcontroller is the brains of the operation and the main component of this tutorial. In the middle of the microcontroller you can see a small black square. It’s a chip which we are going to manipulate to make that LED blink. I’m going to show you how to do it and keep it really simple.
So, you are going to need:
- A breadboard
- A yellow LED (you can get them via eBay)
- A 47 Ohm resistor
- An Arduino Nano
- A mini-b USB cable (I’m going to explain why I will need it)
- And a computer
To start with, let’s have a quick look at this microcontroller.
There are different types of Arduino boards (Arduino Uno, Due, mega etc.), but Arduino Nano is really good for beginners and it’s very simple to use.
If you look at the package bag, the first you can see a note on a yellow background: “CAUSION. Static sensitive devices not to be handled by unauthorized personnel”. Therefore, be certain you get a permission from somebody who’s authorized. Let’s open it.
This is an Arduino Nano and there is a little chip which is the brain of the whole thing. There is a little switch on here and there is a USB socket.
Yearlier I’ve mentioned a mini USB. What you do is plug one end in here (in this mini USB) and plug the other end into a PC or a laptop.
These little holes here are easier for you to solder on. If you don’t want to sold (if you don’t have a soldering iron) just buy a presoldered one and you don’t need to do any more soldering.
For those who are going to solder by yourself I’m going to show you how to do it. I usually just put pins in, then push it into a breadboard (and it holds it for me) which makes my work easier.
When I begin solding, I usually start from the furthest away. Sometimes if the sold lines get dirty, I just whack it on a hard surface. As a result, the plastic bit and the rubbish comes off.
Then you have to solder the other side exactly in the same way.
Small tip: When you are soldering is something is not holding still, you can put something underneath the other side.
Now we’re done with soldering. And we need this breadboard for connecting things together.
We’ve got the Arduino Nano pushed into the breadboard now, and the next thing we want to do is add in the LED. If you take your LED, you’ll notice that there’s a long side and a short side. The long side is plus (+) and the short side is negative (-). We get the long side and just push it into where it says D2.
You see little holes, and they all are linked in a line. Push the long side of the LED into any of the holes of D2 and the short one join it over to the rail (look at the picture above), so the short side is in the rail.
Now get your resistor. The hole next to the LED will be minus (look at the picture above). Push the resistor in there, and then push the other side into the ground pin.
Now you have the resistor in the same rail as the minus pin of the LED. What’s going to happen is that D2 is going to provide it with a voltage. It’s going to be a circuit from D2 across LED and then through the resistor underground. The resistor protects the LED from too much current.
What you need to do next is to plug the mini USB in, and then plug the mini USB into the computer or the laptop.
The way this works is as follows. There is a hardware side and a software side. And we’ve done the hardware side, and now we need a software side. What I mean by the software side is that you’ve got to write a small program which gets flashed onto the little chip. What I mean by flashed is basically you write a program and it gets popped onto the chip, and then the chip runs that program constantly which you write. To be able to do this, you need some software.
If you just go to a search and type in Arduino or Arduino CC, you’ll see the Arduino home page. Go on to that and then go to Software, then go to download the Arduino IDE. Click on windows installer.
When it’s downloaded, click on it and it should come up opening Arduino. It will ask you to install it. After installatioon you have to press NEXT. When it’s finished, you should find that there is a blue icon with a white infinity symbol. That’s Arduino Studio. Click in this icon, and then there will be a window, requesting a code. Just to make sure, go to File and then press New and New comes up.
This is where you write in the code to be able to flash over to the Arduino. At this point, you’ve got the Arduino plugged in. Go to tools, and then go to board. Make sure you choose the Arduino Nano, because it is what we are using.
Make sure you got the following information:
Processor Atmega 328; then select AVR-ISP-MK2.
Then you have to choose a port. If you got several ports, you have to work out which port it is (COM4)
1. Select the port that’s appropriate and then let’s write a code. Write “pinMode”, then open bracket and write “2” and then “output”: (2,OUTPUT).
This code loop repeats forever. We write here “digitalWrite” (2,HIGH), which means “get pin 2 and set it high”.
Then we want to delay the program for 1000 miliseconds. For that we need to write “delay(1000)”. Then text “digitalWrite (2,LOW). After that for another delay for 1000 miliseconds you should text “delay (1000)”.
The sketch is complete. It should look like this:
pinMode(2, OUTPUT)
digitalWrite (2, HIGH)
delay(1000)
digitalWrite (2, LOW)
delay (1000)
What we have: with 2, HIGH the LED on, then we wait for 1 second, then we with 2, LOW the LED off, then we wait for 1 second and the loop repeats.
Our LED start blinking.
We’ve done this, just click upload. It might ask you to save it. Upload it into IOS board.
If we go back to Arduino now you can see that it’s blinking according to what we’d written in that small program.
Here’s how to program Arduino Nano.
Hope now you realize how easy it is to do it. Of course, it was the simple introduction to the programming but you’ve got an idea anyway.
Leave a Reply