In this article,you will learn: 

  • What is Arduino

  • Three basic code templates

  • Using the code programming Arduino UNO board.


Arduino this, Arduino that. Maybe you’ve heard of it before, maybe you haven’t. Chances are, you haven’t — and even if you have, you probably have no idea what it is, what it can do, or why you should even care in the first place.

A lot of people label Arduino as “Lego for techy adults”, and it’s true, at least in the sense that it lets you create amazing things by combining a bunch of tiny little components together into all kinds of arrangements. But it’s much more than that, too.

Even if you aren’t a techy individual, you should still try Arduino. Not only is it a lot of fun, but along the way you’ll sharpen your mind, pick up several useful real-life skills, and build a bunch of satisfying stuff. 

What is Arduino?

Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It’s intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments.

Arduino is a microcontroller on a circuit board which makes it easy to receive inputs and drive outputs.Some examples of inputs would be a temperature sensor, a motion sensor, a distance sensor, a switch and so forth.Some examples of outputs would be a light, a screen, a motor and so forth.

A microcontroller is a integrated computer on a chip.

OK,if you think this is too difficult to understand,we can give a simple example.

We all have desktop PC on our home. As we all know,there are three important things for desktop PC,they are mouse,computer host and monitor.The computer host just likes brain of computer.The mouse inputs information to the brain and the monitor outputs information to us.

Arduino just likes a computer without mouse & monitor. Arduino needs to use with other modules and we call these modules for shields.

Arduino is a small computer that you can program to read and control electrical components connected to it.


Obtaining an Arduino Board

There are several online distributors that stock Arduino boards.

Often boards are bundled up with starter kits. Kits include a wide variety of inputs, outputs, resistors, wires and breadboards. Breadboards are solderless circuit prototyping boards that you can plug wires and components into.

Arduino comes in different flavours. Most people starting off go for the UNO board. It’s current revision is the third, hence the R3 listed by stockists.

Programming Arduino

For the example I’m showing you’ll only need the Arduino UNO R3 board itself and the required USB cable to transfer the program from your computer to the board.

On the board left ,there’s an LED with the letter ON next to it; some small lights, with the letter RX, X1, L next to them.

If you notice on the top edge of the board there’s two black rectangles with several squares in. These are called headers. Headers make it easy to connect components to the the Arduino. Where they connect to the board is called pins. Knowing what pin something is connected to is essential for programming an Arduino.

The pin numbers are listed next to the headers on the board in white.

The onboard LED we want to control is on pin 13.

We’re going to switch it on and off and then look in to making it blink on and off for every second.

When you first plug your USB cable in to your Arduino and your computer, you may notice that this LED is blinking. Not to worry! It’s the default program stored on the chip. We’re going to override this.

The USB cable powers the device. Arduinos can run standalone by using a power supply in the bottom left of the board. Once you’re done programming and don’t require it to be constantly connected to your machine you can opt to power it separately. This is entirely dependant on the use case and circumstances you want to use the device in.

Download Arduino Software(Arduino IDE)

You’ll need to download the Arduino Software package for your operating system from the Arduino download page.

Because my operating system is Windows, so I take the windows version for example.

When you’ve downloaded and opened the application you should see something like this:

This is where you type the code you want to compile and send to the Arduino board.

Three basic code templates

Before starting to write code,you should know the most basic instruction code templates.Here,I will introduce three basic code templates to you.

1. pinMode(pin,Mode);

The pin in template is from 0 to 13 and from A0 to A5.

The Mode in template is INPUT or OUTPUT.

So,if you want to let LED blink,you should let pin 13 output the power to the LED, you should type pinMode(13,OUTPUT);

2. digitalWrite(pin,status);

The pin in template is also from 0 to 13 and from A0 to A5.

The status in template is HIGH or LOW.

So,if you want to let LED blink,you should let pin 13 know its status.The HIGH means the LED is on,and the LOW means off.

At first,we need the LED on,so we type: digitalWrite(13,HIGH);

3. delay(time);

What we need note is the time is in milliseconds.So,if we want to the LED blink for 1 second,we should type: delay(1000);

So, your basic sketch or program should look like this:

1 void setup() {
2   // put your setup code here, to run once:
3 pinMode(13,OUTPUT);
4 digitalWrite(13,HIGH);
5 delay(1000);
6 digitalWrite(13,LOW);
7 delay(1000);
8 }
10 void loop() {
11   // put your main code here, to run repeatedly:
13 }

But this code will just let the LED blink for 1 second,what should we do if we want it blinks for every second?

Have you seen the void loop code in IDE?Yes,they are what we need.You can simply think of void loop as a repetitive command code.So,if we cope the  


to the void loop,it will repeat this command until the UNO Board is powered off.

OK,we have finished the code.And then,we need to setup the environment to Tools menu and select Board.

Setup the environment

Now,connect your UNO Board to your computer using the USB cable.

Then select the type of Arduino you want to program, in our case it’s the Arduino Uno. And then select the port,for me ,it is COM4.                                  

Next we want to compiling the sketch and upload it to the Arduino.

When you have done all above,your arduino UNO Board’s LED will blink every second like this.

Congratulations!You have learned the simplest programming code.



Please follow and like us:

Leave a Reply

Your email address will not be published. Required fields are marked *