Arduino Coding Basics. We have already discussed the popular Arduino Boards, Arduino IDEs, and Installation process of the Arduino software. We learned that Arduino IDE (Integrated Development Environment) allows us to draw the sketch and upload it to the various Arduino boards using code. The code is written in a simple programming language similar to C and C. The Arduino language is C, but it is very different from most C varieties. The Arduino language has a lot of abstraction built in, especially in the hardware interfaces, which makes it very simple to use. If you have a background in Java, C and C should be very similar. The main differences between Arduino and C are in the memory storage.
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.
- What Is Arduino? Well, first things first: What is Arduino? Let's take a look at the.
- ArduBlock - A Visual Programming Arduino Extension. ArduBlock is a graphical programming add-on to the default Arduino IDE. Instead of memorizing cryptic functions, forgetting semicolons, and debugging code, ArduBlock allows you to build your Arduino program by dragging and dropping interlocking blocks.
- What language is used for writing an Arduino program? Embedded C is used to write the Arduino programs. It is used for applications that very near to the hardware. That directly communicates with the hardware.
Sketch − The Arduino program terminology is called “sketch”.
Arduino programming structure
The Arduino programming structure consists of two function, one is Setup( ) function and another one isLoop( ) 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 of the Arduino board.
Loop( ) function
After creating the setup() function,then the loop() function is called in 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
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 understanding 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. 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
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.
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.
Arduino Programming Language For Beginners
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.
Arduino Programming Language Download
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.