Arduino Programming for Beginners Part 2

Introduction: Beginners guide to Arduino & other Micro-controllers [ Boateng Oduro @ www.sirboatengonline.com]

 

Software Overview 


Well, you can't access the world wide web without having a connecting medium, can you?. It is equally true that you can't enjoy the benefits of the Arduino board without knowing how to code.
Arduino hardware and software work hand-in-hand. As the hardware allows you to connect other peripherals (sensors and other components) so that it can interact with the outside world, the software directs the hardware with a series of instructions and dynamic routines.
This part is about a brief introduction to the programming language, IDE and also installing the necessary software and drivers. This tutorial is part of a series "Arduino Programming for Beginners". To get started you may need to read the first part here (overview of the Arduino hardware).

It is practically impossible to socialize with someone who doesn't understand your language and enjoy it fully. talking, texting and of course, sign languages are all part of enjoyable socialization.


Computers and other embeeded systems do talk and oh yes! in their own language (binary codes). But I must confess that there is a vast difference between computer and human languages in terms of their flexibility. Humans are able to comprehend lamguage with grammatical errors, mixed dialogue and broken phrases. Unlike humans, machine languages are very strict and sensitive. To talk to machines, you have to follow a set of rules and procedures (which can be analogize to grammatical rules) in a form of instructions. These instructions are what we called the programming language.

To code (communicate and control machines), one needs to learn a programming language.


WHAT IS PROGRAMMING LANGUAGE?

A programming language is a set of grammatical rules, commands, instructions, and other syntax use to create a software program and also for instructing a computer or computing device to perform specific tasks. 

There are two main types of programming language namely: High level and Low level

A high-level language (HLL) is a programming language that enables a programmer to write programs that are more or less independent of a particular type of computer. Such languages are considered high-level because they are closer to human languages and mathematical notation.

Examples include: C, C++, Java, Pascal, Python, Visual Basic.

Low level languages are used to write programs that relate to the specific architecture and hardware of a particular type of computer. They are closer to the native language of a computer (binary code), making them harder for programmers to understand.

Examples include: Assembly Language, Machine Code.


Fig 1. Comparing a simple program written in LOW and HIGH-level languages

The diagram above illustrates how high and low-level programming language is done. You will bear with me that low-level programming languages are very difficult to learn. It is therefore NOT surprising to see all developers are only conversant with high-level programming languages.

The diagram below shows some of the common Programming Languages available


Fig 2; Common programming languages

 

 

 

 

 

 

 

 

 

 

 

 

 

 

   

 

 

IDE AND TEXT EDITORS

IDE stands for “integrated development environment”. they contain compilers that change the high-level programming language to machine codes.  They also come with a text editor for writing the codes.
Common IDE’s are: Arduino IDE (Eclipse), MPLAB, Visual Studio, Android Studio.
Choosing an IDE depends on the type of programming language you want to use. Since we are learning Arduino, we will be using the Arduino IDE.

The Arduino IDE is installed the same way most windows applications are done. They are free to download and open source so there is no need to worry for a license key. Go to https://www.arduino.cc/en/Main/Software and download the latest version for your specific operating system.


Fig 3; The Arduino IDE


Now that you have installed the IDE, let's see what the Arduino language is and the syntaxes we can use to create amazing projects.


The Arduino Language Reference


Just like we can identify parts of speech in the English language (noun, verb, adjective, etc.), the Arduino programming language can also be divided into three main parts. These are Structure, Values (variables and constants), and Functions.



Structure

The Arduino Structure is the elements of Arduino (C++) code. This constitutes the syntax used in C++ programming language. A structure must be specified exactly as used in the C++ library. The structure, therefore, defines the specific rules that must be followed to get the rest of the code working.


Fig 4; Arduino Structure


 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Values (variables and constants)


Arduino data types and constants. These are the types of values and constants that can be processed by the Arduino. To understand Arduino variables and constants, we need to analogize the phenomena with the file format. For example, the VLC media player is specifically designed to play media file formats (such as mp3, mp4, Avi, etc.). there is no way a vlc program will play an office file formats (such as .doc, docx, pdf, etc.). As u can see, the type of file format associated with the Arduino language is the values. A value that can be changed/altered when the Arduino is executing the instructions is “Variable” and those that are fixed and cannot be altered during the program execution are “constants”.    
Fig 5; Arduino Variables and constants



 

 

 

 

 

 

 

 

Functions.


The function is used for controlling the Arduino board and also for performing computations. We will use a function to turn a pin ON or OFF or to set a pin to OUTPUT current or as INPUT to receive an incoming signal.

Fig 6; Arduino functions





























The three (parts) of the arduino language are listed above. As you can see, they have been colored to distinguish from each other. The Arduino IDE uses the same colors to tell you the part in which a piece of code belongs. 

A code with orange color is a function, a blue colored code is a value (variable or constant) and a code with green color is a structure. 

At electrotekgh, we learn by doing. Therefore I will explain in details the functions, variables and structure by doing mini projects with them. 

I hope by now, you have geared up for a higher level. Of course, we have a very huge mountain of projects to climb but until then, relax and have a stressfree day. farewell!. 

electrotek!!!! together we can!



Labels: , , , , , ,