Basics of Arduino Coding

Basics of Arduino Coding

This entry is part 1 of 8 in the series Arduino Tips & Tricks

You don’t require to know anything about coding before reading this article.

We are starting it from scratch…!

Arduino coding is very simple to understand and use in embedded system programming. We will discuss basic details about Arduino coding in this article so that you will be quite confident to start with Arduino coding and design your own circuits and ideas and projects using Arduino.

Here we assume that you have already installed Arduino IDEWhat is Arduino IDE? Arduino IDE stands for Integrated Development Environment. It is also called as Arduino software in general language or Arduino compiler. It is used to convert high level programming language like C/C++ program into machine code i.e. into low level language. i.e. Arduino compilerWhat is Arduino IDE? Arduino IDE stands for Integrated Development Environment. It is also called as Arduino software in general language or Arduino compiler. It is used to convert high level programming language like C/C++ program into machine code i.e. into low level language. software on your Windows PC. If you have not installed it yet, visit this direct downloading link of the software.

When downloading is complete, search the “arduino-1.8.19.zip” file in download folder of your PC, unzip the file by double clicking on it and then double click on “arduino-1.8.19.exe” file inside the zipped folder to start the installation of the software.

Now when you are ready, start reading the following topics. Remember it’s a series of posts to learn complete coding techniques about Arduino.

So when you complete reading the 1st post, continue with the 2nd post and 3rd post and so on.

Take your own time to understand each topic completely and then go to the next post in this series.

Coding Structure

The coding structure in Arduino programming is very simple. You must have at least two basic or default functionsMeaning of function in coding A function in any programming language is defined as the group of commands to carry out a particular task. It is necessary to note that all the commands in a function will execute a particular task, together. in every Arduino code, as shown below.

 void setup()
 {
  statement1;
  statement2;
  ..........
 }
 void loop()
 {
  statement1;
  statement2;
  ..........  
 }

Control Structure

When you write a particular program in Arduino IDE to control some hardware (firmware) circuit, then you will need some controlling commands with which you will be able to control the behavior of the hardware (firmware) like a robotic trolley to move it forward, backward, stop in front of an obstacle, then turn and so on.

There are different types of control structures used in Arduino, as follows -

The 'if-else' condition

The 'if-else' conditions are used to perform either this or that task i.e. when you want to perform a task when a particular condition is true. If that condition is not true i.e. false, then the control is passed on to 'else' condition.

 if(int i=5)
 {
  // write your commands below, 
  // which you want to execute when i=5
  command1;
  command2;
  ........
 }
 else
 {
  // write another commands below,
  // which you want to execute when i not equal to 5
  command3;
  command4;
  .........
 }

Signup or Login to view remaining content. It's Free!
Share on your network!
Dattaraj Vidyasagar
Dattaraj Vidyasagar

Author on this website. He is veteran of Core Electronics since last 35+ years. ATL Mentor of Change, Niti Ayog, Govt. of India, Google Certified Educator, International Robotics Trainer and author of 17 books on electronics, robotics, programming languages and web designing... ➤➤

Leave a Reply

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