21st century is the era of integrated electronics devices and gadgets. Nowadays almost everything is controlled by a processor, through certain algorithms and AI based instructions. Processor is a computing machine which performs computation and gives instruction to every part of machine. You have often heard that processor is called brain of computer, it is because of its numerical computation and instruction providing nature. Microcontroller is a subset of microprocessor which is used for a specific purpose only. We are to program a microcontroller using one of the language, available in market such as C/C++, assembly or Rust programming language (Most loved programming language on stack overflow).
Arduino– for non-technical persons:
Programming a microcontroller requires keen knowledge of register function, memory components, DAC (Digital to analogue converter) and ADC (Analogue to digital converter), debugging software, burner(wire that connect Arduino to our laptops for programming- cross platform development), linkers etc. So historically, a person has to type out a lot of binary and use registers and memory instructions. Along with custom made interfacing devices using to upload the code onto the microcontroller. Therefore, it is unlikely for a nontechnical person to master them, many engineering students also need to use a microcontroller for their projects. Hence, a couple years back ARDUINO boards were introduced by a company in Italy, they basically use a third party software and hardware and they are microcontrollers designed to just implement the task given, without prior knowledge to its internal components. They also developed their own programming language which is easily configured and understandable.
There is a bonus for viewers, use the code RANDOM NERD to get special discounts on the following online course, which covers almost everything starting from interfacing it with different sensors and motors. It basically is a great course to understand Arduino Language, its communication with different modules.
Arduino Tautorial :
So, here I am going to introduce some guidelines and information to start with the Arduino. If you google Arduino, there is a ton of stuff available but, nobody covers the basics. They just start with different projects, provide the code and like a robot, people start copying, rather to understand it. Take for example, the above course which I had mentioned, they don’t cover the basics. Even when I started learning Arduino, I copied the code, but realized afterwards, that this is going to cost me a fortune, because I was unable to write of my own. So, started reading books which covered the basis of Arduino,which made me realize, ‘BASIS ARE VERY IMPORTANT’. You can easily get these books from Amazon at a great deal, both of these books cover almost each and everything about Arduino.
1- Arduino for beginners: A step by step guide
2- Arduino for everyone
3- Arduino for Beginners Book
To learn more what internet of things is and role of microcontroller in internet of things, click here
Details before Purchasing Arduino Microcontroller :
So, let’s start, Arduino comes in many packaged hardware boards, like Arduino UNO, MEGA, YUN, DUO, NANO and so on depending on the requirement, we can select the board. Arduino UNO is the most common and widely used board, as it is fairly cheaper and comes with a complete package. AT Mega 2560 by ATMEL, is widely used as the CPU/processor in these boards, as seen in the photograph below. To upload the code from the computer to the Arduino, there’s another smaller microcontroller on the board, which is used to upload the code to the main microcontroller, this allows communication between the computer and the main microcontroller. This is also used to send and receive messages between computer and the main microcontroller, when the software is being used. It gives real time information to the serial port Monitor. This board is extremely important for debugging.
FIGURE 1 LAYOUT OF THE ARDUINO BOARD.
This processor is connected to the PINs (digital and analogue) as shown above. On the right side of the board, we have digital PINs from zero to 13. Their function is very much simple, they usually give 5V at high state and 0V at low state, as shown below in the figure 2. These digital pins can be configured to either take the output or the input, which is to be configured by the IDE. Some digital pins (having tilde) are also set to provide PWM signals, i.e. pulse width modulation. It is a concept which can be used to control how much of the output, out of 5V is applied. In other word, it controls the speed of the motor rotation, the brightness of an LED light, like a dimmer controls the fan speed. There are 2 pins on the bottom right of the board called the TX and RX. They are used to transmit and receive the, from other boards and acts communication bridge between other boards, like sending or receiving the data from Bluetooth, WIFI or the GPS module.
FIGURE 2 OUTPUT OR INPUT GIVEN BY DIGITAL PINS.
On the left side, there are 6 analogue input PINs. These pins are designed to just accept the input from the source. They provide the complete and precise continuous voltage values, i.e. not the high and low. Their range is between zero and 5V. Some pins required for the power options are also located at the top of analogue pins. They include
- VIN, used to power the Arduino.
- 5V, connected in parallel with the VIN pin and provides a 5V output from the Arduino.
- 2 ground pins to complete the circuit, usually at zero volts, they are usually shorted to each other.
- 3V pin, which provides 3.3V output.
To power the Arduino with the computer, there’s an N USB wire, comes usually with the board, which connects it with the computer. It can be powered using the DC pin or the VIN pin. The optimal working voltage for UNO is 5V, but for MEGA is 3.1V. UNO also has a 5V voltage regulator, which regulates the DC 9V volts to 5V. It also has a reset button to reboot your board.
We have covered the hardware part, lets focus on software part, which allows to control the board, for specific purposes. Hence, we need to program the Arduino for its specific tasks, for this the board is connected with the computer. Moreover, we need a platform to code it. Hence, special IDE platform was developed for Arduino, called the Arduino IDE, which can be downloaded from the following link.
After installing the IDE, the following main page is displayed. This is where we have to code, which includes the main setup, where you can configure your Arduino to evaluate certain tasks for the duration of program, it could have information regarding the PINs connections and their types, and the loop portion, which repeats itself until reset or power cut off. Their function is written in the comments denoted by double forward slash.
As we are using an Arduino UNO board so we need to configure the environment required for its function, hence click on Tools option in the menu bar which shows a dropdown menu, then click on board option. Board option contains numerous Arduino boards, select UNO. Then click on port option in the same tools dropdown menu and select the USB port of the computer to which Arduino is connected. Arduino IDE also has a SERIAL port monitor, which allows us to simulate the program, acting as a monitor to check the values received by the hardware.
One of the key features of using this IDE is that it provides the example code for almost all of the basic projects. Beginners can start learning the syntax from them. You can also learn to code from online courses and websites. Books available online are also a good way to learn interfacing.
Some of them are mentioned below,