How To Program Arduino With C++

How To Program Arduino With C++

Arduino is an extremely popular low-cost electronic board to build simple IoT devices running with a software similar to a C++ code editor. It is an open-source electronics platform based on easy-to-use hardware and software. Arduino boards are able to read inputs and turn output ports on and off. In Arduino programming you can use C++ classes and objects; you can create methods for these classes i.e C++ constructor, destructor, etc. You can interact with this kind of IoTs with C++ Builder too.

You can create great IoT solutions using Arduino and the C or C++ language with it. For example, it may receive a signal from a light-sensitive sensor, a finger on a button, or a Twitter message via a WIFI board and it can be used to activate a motor, turn on an LED, or make a beep via output signal from its ports. It is a very versatile platform which can be, and is, used for all sorts of real-world uses ranging from soil moisture content sensors, home security alarms, baby monitors and many other uses. Arduino devices are one of the fundamental underlying technologies used in the Internet Of Things or IoT. But can I program Arduino with a C++ IDE?

How To Program Arduino Device With C++ ? What is Arduino ?

Thanks to the Open Source design of Arduino the are a great many variations on what an Arduino device looks like ranging from plain circuit boards up to fully self-contained packages which are ready to use. Here’s a selection of a few different types.

  • How can I program Arduino in C++? The M5Stick is an Arduino compatible device
  • How can I program Arduino in C++? A picture of an Arduino Nano
  • How can I program Arduino in C++? A picture of an Arduino Uno
  • How can I program Arduino in C++? The Seeed Wio Terminal

How To Program Arduino With C++?

Developers can develop apps for the Arduino via Arduino’s own IDE easily. The developer tells the Arduino board what to do by sending a set of instructions written in a subset of C/C++ functions, to the microcontroller on the board. While it uses the C/C++ language, because of its different main program structure and because of its specific commands for its board, it is called as the Arduino programming language (based on Wiring), and the Arduino Software (IDE), based on Processing. List of Arduino boards and compatible systems can be found here.

How To Use Sketch To Program Arduino With C++?

The Arduino IDE refers to its Arduino version C++ programs as a “Sketch” and collectively refers to the source code files as “Sketch files”.

The Arduino programming language can be divided in three main parts: functions, values (variables and constants), and structure. The complete Language Reference can be found here:

How To Use Arduino IDE to program Arduino With C++?

Ardunio IDE is a kind of text editor or code editor which supports C/C++ functions. The main difference of the Arduino C++ version is it has setup() and loop() functions instead of a main() function in standard C/C++. and it has specific definitions and commands for the ports of Arduino and for its CPU. Mainly it has two different IDE versions 1.x version and new 2.0 release to candidate version.

Arduino IDE 1.x.x (1.8.19) : The open-source Arduino Software (IDE) makes it easy to write code and upload it to an Arduino compatible board. This software can be used with any Arduino board. Refer to the Getting Started page for Installation instructions. Active development of the Arduino software is hosted by GitHub. See the instructions for building the code. The very latest release source code archives are available here.

Arduino IDE 2.x.x RC(2.0.0-rc9) : The new major release of the Arduino IDE is faster and even more powerful. In addition to a more modern editor and a more responsive interface it features autocompletion, code navigation, and even a live debugger. The Arduino IDE 2.0 is now moving to stable status with a series of Release Candidate (RC) builds.

Arduino IDE 2.0 (Source:

How to program Arduino with C++ or C?

The Arduino uses a version of the language that all standard C and C++ constructs supported by avr-g++ should work in Arduino. The Arduino language is merely a subset of C/C++ functions that can be called from your code. Your code (called as sketch) undergoes minor changes (e.g., automatic generation of function prototypes) and then is passed directly to a C/C++ compiler (avr-g++). The main difference is it has a setup() function which initializes the device into a ready state. After this a loop() function acts as the central processing controller instead of a main() function that we would find in regular C and C++. The setup() and loop() functions look just like regular C/C++ except it has a number of specific definitions/constants and commands for the ports of Arduino and for its CPU. For more details, see the page on the Arduino build process.

Here is the main program structure of the Arduino app. It has two main functions, setup and loop, and loop is like a main function.

How to program Arduino with a regular C++ IDE?

You do not have to use the official Arduino IDE to program Arduino compatible devices. It is possible to use the Eclipse IDE or Visual Studio Code to write programs for Arduino.

Arduino official web page includes a lot of examples, one of the simplest example is a blink example that turns on and off a led on this device. Here is the simplified blink example,

We may enhance this simple blink example with Object Oriented Programming features of C++. We can add a Tblink class with on() and off() methods and we can use it as below,

as you see it is easy to use C++ features in Arduino.

How To Program Arduino With C++ Builder IDE?

In theory yes, if you send program instructions to the port of Arduino, you can. In practice though it is best to use the Arduino IDE to send the individual Arduino Sketch programs down to the Arduino device. The greatest strength is then to use C++ Builder or RAD Studio to develop C/C++ apps and projects with FMX / VCL frameworks.

Those VCL and FMX C++ apps can interact with the Arduino board signals and trigger their inputs and outputs. Here is a tutorial about how to use Delphi and serial port, C++ version would be about same,

There is also an excellent tutorial and demonstration by Embarcadero MVP Ian Barker and Technology Partner Serge Pilko showing how to use the Arduino IDE and RAD Studio together to create real IoT programs. The tutorial and video are on our sister site


C++ Builder Professional, Enterprise and Architect Editions are able to run C programs. There is a free C++ Builder Community Edition for students, beginners, and startups too. You can download, install and run your C and C++ programs in console applications. Moreover you can enhance your C programs with C++ features and modern GUIs, which means you can mix and use C and C++ together. For the best modern app, later if you wish, you can update your C program to a C++ program.

Why not download a free trial of the latest version of RAD Studio now?


Oh hi there 👋
It’s nice to meet you.

Sign up to receive awesome C++ content in your inbox, every day.

We don’t spam! Read our privacy policy for more info.

About author

33+ years of coding with more than 30+ programming languages, mostly C++ on Windows, Android, Mac-OS, iOS, Linux and some other operating systems. Dr. Yilmaz Yoru was born in 1974, Eskisehir-Turkey. He graduated from the department of Mechanical Engineering of Eskisehir Osmangazi University in 1997. One year later he started to work in the same university as an assistant. He received his MSc and PhD degrees from the same department of the same university. He has married and he is a father of a son. Some of his interests are Programming, Thermodynamics, Fluid Mechanics and Artificial Intelligence. He also likes the graphical 2D & 3D design and high-end innovations.
Related posts
CC++C++17Introduction to C++Learn C++

How To Run A C++ Program In The Linux Terminal

C++C++17Game DevelopmentLearn C++

How To Program A Game In C++

C++C++17Introduction to C++Language FeatureLearn C++

What Is C++ Programming Used For?

C++C++17Introduction to C++Language FeatureLearn C++

How To Run A C++ Program