Learning Circuitry Part 2: Everything You Need To Know About The Arduino

by Doug

 July 11, 2016

What comes to your mind when you hear the word “digital”? Most people associate this word with a stream of binary digits, 01010110.

But what is the science behind this binary stream? How do digital devices work and why are they overtaking every analog device that comes in their way?

The answer is quite simple: microcontrollers. We all know that at a core of every computer sits a microprocessor that collects data from the storage and manipulates it to produce results. And no doubt a computer can help with several types of applications, however when it comes to industry-specific prototypes, installing an entire machine is not exactly cost-effective.

Instead, developers came up with something much more manageable, a circuit or board that contains a processor, memory and programmable I/O units, i.e. the microcontroller.

You can think of a microcontroller as a self-contained system. They are used in almost every industry from automobiles to communication systems to kitchen-ware.

In this article, you will learn all about the Arduino and we’ll even be creating a blinking LED project!

Previous article

Table of contents:

 

What is an “Arduino”?

There are several microcontrollers available in the market for commercial use, one of which is the Arduino Microcontroller. Arduino is the whole package; it is an easy-to-use, powerful single-chip machine that can jump-start any engineering/electronics enthusiast’s dreams to their own gadgets easily.

The Arduino project started in Italy with the main focus of developing a low-cost hardware platform for interaction design.

Eventually, it turned open-source, a step that gave it a huge boost in the home-developers’ market. Today, the board is used not only by college students or people looking to make their own appliances but also in small to medium scale industries for automation.

Every computer, laptop or mobile phone evolves with the passage of time. Soon there are several models available to choose from. Same is the case with Arduino; there are several models, each with its own specs and characteristics.

Some of the Arduino boards in the market are:

  1. Arduino Diecimila in Stoicheia
  2. Arduino Duemilanove
  3. Arduino UNO
  4. Arduino Leonardo
  5. Arduino Mega
  6. Arduino Nano
  7. Arduino Due
  8. LilyPad Arduino

Assuming you’re a beginner, it would be much better if you start building a solid foundation before jumping right into advanced concepts.

The Arduino UNO is the best possible choice for any person looking to gain a healthy insight of the workings of a microcontroller.

The board is cheap, has a minimalist design, and yet still manages to accomplish a whole lot of things. You can purchase other variants as well because in the end the language is the same, but be careful as accidently damaging an expensive board can burn a hole through your pocket.

Pro tip: You’ll notice that the Arduino retails for around $20. Since Arduino is an open source hardware, other companies are allowed to use the schematic to build their own Arduino variations. If you go to a site like AliExpress, you’ll notice that Arduino Uno’s cost as little as $2-$5. The only difference is that you’ll have to wait a few weeks for your Arduino to arrive since they ship out from China.

Still, I recommend at least buying one Arduino in your lifetime from the original Arduino company. Although they are perfectly ok with other companies making clones of their products, it’s always good to support the original company that invented this product.

 

The Advantages of Arduino

Arduino has some major advantages that put it at a lead when brought head to head with a raw microcontroller. Some of these are:

  1. Ready to use – this may be the biggest advantage of this microcontroller. Arduino comes in a complete package that includes a 5V regulator, burner, oscillator, a microprocessor, and onboard storage. Basically, the whole 9 yards. You can develop a temperature sensor unit within minutes simply by a hooking the related components and burning the code. No lengthy middle-man processes are required.
  2. USB interface – common microcontrollers require special code burners to transfer desired code onto them. This means not only will you have to invest in the microcontroller but you’ll have to buy a code-burner as well. Arduino comes with a USB interface through which you can burn your code onto it without any hassle. This reduces time by a significant amount as well as trial time.
  3. Community – since its inception, the Arduino community has grown with leaps and bounds and is now one of the largest in the world. Almost all types of codes have been written and refined so no matter what you’re trying to develop, chances are someone has done it before. You can grab the basic idea from the given code and modify it to your own needs.
  4. Syntax – for those of you who are entirely new to coding, learning Arduino may come with a bit of a curve. However those who are familiar with the basics of languages like C, C++ and Java. they’ll be delighted to hear that Arduino uses syntax almost identical to C++!
  5. Cross-platform – it doesn’t matter whether you’re using Linux, Mac or Windows, Arduino’s IDE runs on all Operating Systems and has the same level of support without any discrimination.
  6. Cost – the cost of this board is one the main reasons for its unprecedented popularity. Not all university students can afford expensive microcontroller sets for experimentation. But Arduino provides a great alternative to industry level boards as it comes with all the functions a student could possibly want. For instance, Arduino UNO comes at only $30. There are no addition or hidden costs to the board.

 

Arduino Pin Configuration

How do you interact with Arduino? Through an array of pin connections that can be made to external components like batteries, resistors, capacitors, LED panels, etc. The pins are labelled so you won’t have any problem looking for them:

Arduino UNO
Arduino UNO
  1. GND – also called “ground”. The ground pins can’t be used to earth your circuit. There are usually 2 – 3 ground pins.
  2. 5V & 3.3V – these pins are for supplying different levels of DC power to the board. The power is then distributed onto the attached components.
  3. Analog – all the pins that fall under “ANALOG IN” label are analog pins. They are labeled A0 – A5 on Arduino UNO and are used for inputting signals from analog components mostly temperature or pressure sensors. The signals are converted into digital form.
  4. Digital – these are located all the way across from analog pins and can be used for digital inputs as well as outputs. An example would be lighting an LED on/off.
  5. PWM – among the digital pins are a few that are labeled with ~. These are Pulse Width Modulation pins. This is something that’s out of the scope of this article. For now, think of these as output pins that can not only light an LED on/off but can also change its brightness.
  6. AREF – leave this alone for now. Known as the analog reference pin, this is used for external reference voltage.

 

Getting set up

After purchasing your Arduino board, the first thing you’ll need to do is install the Arduino IDE Software. You can get the latest version from Arduino’s software download page.

Choose the “Installer .exe” package as it is much simpler that the Zip package. The installation procedure is quite simple. Check all the boxes that appear on-screen and in no-time you’ll be done.

Connect the board with your computer through the USB cable. The green LED should light on, indicating everything is normal. The drivers are installed as soon as you connect the board to your computer.

Note that the board draws its power from your computer so disconnecting it would render it useless. You can also use a battery, but for now stick to the USB cable.

Open the “Arduino.exe” file on your desktop and the IDE will appear. This is where you’re be doing all the back-end development.

Arduino IDE
Arduino IDE

Now, it’s time for your first ever Arduino based application!

 

Blinking an LED with Arduino

I’ll assume that you have an Arduino UNO for this tutorial.

The following is required for this tutorial:

  1. UNO board,
  2. LED,
  3. 1k Ohms resistor,
LED-blink-circuit
Schematic for the blink circuit

In order to build the circuit:

  1. Connect one leg of the resistor to PIN 12.
  2. The long leg of the LED is the positive one while the shorter one is negative. Connect the positive end of the LED to the resistor.
  3. Connect the negative end to the GND PIN.

Next, open the IDE.

In the “setup” block, initialize PIN 12 for use as an output PIN with the following line:

pinMode(12, OUTPUT);

In the “loop” block, enter the following lines to first turn the LED on, wait for 1 second and then turn it back off. (HIGH means on)

  digitalWrite(12, HIGH);
  delay(1000);
  digitalWrite(12, LOW);
  delay(1000);

Now, your code should look something like this: 

  void setup() {
    pinMode(12, OUTPUT);
  }

  void loop() {
    digitalWrite(12, HIGH);
    delay(1000); 
    digitalWrite(12, LOW); 
    delay(1000); 
  }

All the code that’s entered in the “loop” block will keep on repeating itself until the end of times, once burnt!

Make sure UNO is selected as the chosen board by going to Tools > Board.

Finally, press the “Upload” button and witness the magic!

As long as you see no red errors appearing in the Arduino IDE, you should be set! Your LED should start blinking. 🙂

 

Final Notes

I hope you enjoyed the article. This was just the first step to the massive world of microcontroller development. Stay tuned for more!

Next – Learning Circuitry Part 3: The Non-Techie’s Guide to Programming

Tags:



What do you think?


  • Another excellent article; thank you! I was a programmer for many years and am interested in the availability of new microcontrollers for audio and MIDI-related projects; this educational series and recent book are fantastic resources. I’ll be purchasing your E-book very soon.

    * Note: there’s a discrepancy in the code above; the diagram and initial code snippet reference Pin 12, while the second section of code references Pin 13. This could be confusing to some.

    • Doug (Admin) July 17, 2016

      Ah! Fixed it. Thanks! Let me know if you have any questions about the book. It’s getting really good feedback so far. Also, the forum has become a really useful tool for everyone.