Vidyasagar Academy Wishes a Very Happy, Healthy & Prosperous Diwali to all our Students & Teachers!
- Basics of Arduino Coding
- How to use Android Phone to write codes and upload in Arduino?
- Effective coding techniques in Arduino: More about datatypes
- Effective coding techniques in Arduino: More about variables
- How to design Cathode Ray Oscilloscope using Arduino? Code of just 9 lines!
- How to start learning NodeMCU in simple steps? Basic Tutorial on NodeMCU
- How to use array to rotate servo motor in different angles?
- Blinking LED code for Arduino in Assembly Language Programming (ALP)
- Having trouble to drive Servo motor with Arduino Uno SMD? Get perfect solution now…
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.
Introduction
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; ......... }