Arduino is an extremely popular 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. 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 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?
Table of Contents
What does an Arduino device look like?
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++?
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 is 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. https://en.wikipedia.org/wiki/List_of_Arduino_boards_and_compatible_systems
Is an Arduino Sketch program a C++ program?
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: https://www.arduino.cc/reference/en/
Is the Arduino IDE a C++ or C IDE?
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
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.
Can I 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 codes (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.
Can I 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.
Can I program Arduino with C++ IDE C++ Builder ?
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, https://forum.arduino.cc/t/tutorial-arduino-delphi-10-2-and-serial-port/471049
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 is on our sister site LearnDelphi.org: https://learndelphi.org/what-you-need-to-start-windows-development-for-iot-devices/
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.