If you’re new to the world of microcontrollers, Arduino is a great place to start. This open-source platform provides a powerful and flexible way to create a wide range of electronic projects, from simple LED blinkers to complex automation systems.
When getting started, it may not be immediately clear how to code programs on the Arduino to make use of the wide range of resources. We’ve mentioned it’s open-source and free to tinker with, but, what programming language does Arduino use?
The Arduino Programming Language
The Arduino programming language is the main one used on the Arduino and is nothing more than just C++ wrappers built on top of C—after all, C++ is just a superset of C. Essentially, the idea is to hide the complex details when working with hardware to make it “simple” for anyone to program an Arduino.
You may ask why C++/C? The goal is to leverage the speed, efficiency, and low-level control over hardware that these languages provide, but with some noticeable differences in syntax. And the subtle differences are actually what makes the Arduino language user-friendly, while still retaining the full capabilities and power of C/C++.
The language includes built-in functions and libraries that simplify hardware interaction with components like sensors and actuators. These functions abstract away many of the low-level details, making it easier for you to get started with programming your Arduino without having to master the intricacies of hardware interfacing.
Giving a simple example, setting pin 13 high in Arduino language looks like this:
While the equivalent C implementation looks like this:
PORTB |= (1<<PB5)
This is just a hint at how simplified the Arduino language has been made. Here is an example of a simple program (also called a sketch) in the Arduino programming language:
int sensorValue = digitalRead(2);
The Arduino IDE
The Arduino IDE (integrated development environment) provides just enough features for you to get started and has a low learning curve. It lets you write and upload Arduino sketches conveniently. If you feel you need a more feature-rich IDE, you can try Xcode for projects that are primarily AVR-C, as it provides access to a variety of powerful tools and features that make development easier.
Other Programming Languages for Arduino
While the Arduino programming language is the main language, there are other text-based programming languages that can be used. There is an Arduino MicroPython IDE used to program Arduino boards in MicroPython. You can even program Arduino boards using assembly language, Python, and C#.
Alternative languages such as XOD and Snap4Arduino are also good programming languages you can use with Arduino.
The Arduino programming language is a simple and user-friendly version of C++ that’s specifically designed for programming Arduino microcontroller boards. It provides an easy-to-learn syntax and a variety of built-in functions that make it easy for beginners to get started.