Arduino Programing Language | How To Program Arduino
Hello friends! Welcome back to ElectroDuino. This is Arduino Tutorial #3 – How To Program Arduino | Arduino LED Blinking. After understanding How to Download & Install Arduino IDE in Arduino Tutorial #2. In this blog post, we will discuss Introduction to the Arduino Programing Language, How To Program an Arduino in Arduino IDE Software, and as an example, we explain the Arduino LED Blinking code.
Arduino Programing Language
The Arduino software is open-source. The C/C++ Programing Language used in Arduino IDE to write the Arduino program. It is pretty much the simpler form of C language. Arduino IDE all functions and libraries are written in C/C++. Also, we can use Java programming language to communicate with the Arduino board via serial port communication. But Java will just complicate things in Arduino. So, here We will learn how to create a project in Arduino using the C language.
Sketch − The Arduino program terminology is called “sketch”.
Arduino programming Language structure
The Arduino programming structure consists of two function, one is Setup( ) function, and another one is Loop( ) function
Setup( ) function
The setup() function is called when a sketch starts. This function is used to initialize the variables, pin modes, start using libraries, etc. The setup() function will only run once, after power ON or RESET the Arduino board.
Loop( ) function
After creating the setup() function, then the loop() function is called in the sketch. It is also mandatory in an Arduino program. The code inside the loop() function runs again and again. This function does precisely what its name suggests, and loops continuously, also it allowing to change the program and respond. This function is used to actively control the Arduino board.
Arduino LED Blinking Program
Every programming language has a basic code “Hello, World!”. But in Arduino programming, it is an “LED Blinking” code. You are getting this code in your Arduino IDE example section.
We are using this code to better understand Arduino programming. Using the Blink sketch, we will turn ON the LED for one second and turn it OFF for one second, it’s continually running. The Arduino board has a LED, that is connected to Pin 13 of the Arduino.
Also, we will connect an external LED to the Arduino pin 13, to show “how to connect a LED with Arduino”.
Components Required
Components Name | Quantity |
Arduino Uno Board (you can use other types of Arduino board like Arduino UNO, MEGA, pro mini, etc) | 1 |
USB cable for Arduino Uno | 1 |
LED | 1 |
330-ohm Resistor | 1 |
Connecting wire | As per required in the circuit diagram |
Arduino LED Circuit Diagram
Circuit Wiring
LED Pin | Arduino pin |
LED positive (+) terminal | connected to Arduino 13 pin through a 330-ohm resistor |
LED negative (-) terminal | connected to Arduino GND pin |
How To Program Arduino – LED Blinking Program/sketch (Arduino Programing)
At first, open your Arduino IDE software. Then open – File >> Example >> Basics >> Blink.
After following the above process, now you reach the blink LED example code window.
Before uploading the program to the Arduino board, we should “Verify or Compile” the code. Click on the first symbol of the Arduino IDE Menu Bar to “Verify or Compile” the code. Now, compiling is started.
After compiling, if your code has no error then you can see the “DONE Compiling” message on the Output panel of Arduino IDE.
Arduino Programing- Upload Code to Arduino Board
Now code is ready to upload in your Arduino board. First of all, connect the Arduino board to your computer using the USB cable.
Then go to the Arduino IDE “tool” section for select the “Board” and “port”. In my case Board is “Arduino UNO”, you can choose the Board type according to you Arduino and port is “COM6”, but your port may be different.
All important steps are completed. So, click on the “Upload” button. When uploading is successful you get the “Done Uploading” message on the Output panel of Arduino IDE.
Output Result
As a result, you can see Arduino LED and external LED turn ON for one second and turn OFF for one second, it’s continually running.
Pingback: Arduino Tutorial #5 – Digital Pin PWM Output | Arduino LED Fading. » ElectroDuino