Arduino Coding Language: Exploring C, C++, Python, and More

Explore Arduino Coding Language through C, C++, Python, and more. Learn how these languages enhance Arduino projects.

Avatar of Ibrar Ayyub
By Ibrar Ayyub
Published August 6, 2024
At a glance
CategoryBlog
DifficultyBeginner
IncludesCode, Datasheets
UpdatedNovember 24, 2026
Reading timeabout 8 min
On this page

Summary of Arduino Coding Language: Exploring C, C++, Python, and More


Arduino natively uses a simplified C/C++ dialect compiled with GCC, blending procedural C-style syntax with selectable C++ features. The platform also supports pure C, full C++, Python (via pyFirmata), JavaScript (Johnny-Five/Firmata), Go, and visual/block tools (Blockly, MakeCode). Arduino inherits standard C/C++ operators, benefits greatly from extensive libraries, and can leverage advanced C++ capabilities. Trends to watch include Rust, WebAssembly, and more visual editors. Overall, Arduino is a pragmatic, multi-language ecosystem optimized for embedded projects.

Parts used in theArduino Language Overview:

  • Arduino boards (microcontroller hardware)
  • Arduino IDE
  • GCC (GNU Compiler Collection)
  • pyFirmata library
  • Firmata protocol
  • Johnny-Five (Node.js library)
  • Go Arduino packages (eg go-esp8266-wifi)
  • Blockly visual programming tool
  • MakeCode (Microsoft)
  • OCR Boards (educational boards)
  • PXT Targets (MakeCode configuration)
  • Common Arduino libraries (LiquidCrystal, Wire, SPI, Ethernet, WiFi101, Servo, SD, NeoPixel)
  • TensorFlow Lite (for AI tasks on Arduino)
8 min read

Arduino sketches are written in C++. The Arduino software adds a few conveniences (a hidden main(), automatic function prototypes and a library of friendly functions such as digitalWrite()), then hands your code to the GNU C++ compiler. You can also add plain C files, and some boards can run MicroPython instead. This page shows what the compiler really receives for an Uno, what works, what does not, and where other languages fit.

IN SHORT
  • A sketch (.ino file) is C++ with a few automatic extras. The Uno core compiles it as GNU C++11 with avr-gcc 7.3.0.
  • Classes, templates and your own header files work. Exceptions are switched off, and the C++ standard library (for example std::vector) is not included on the Uno.
  • On an Uno, int is 2 bytes and double is only 4 bytes, the same as float. This surprises people who learned C++ on a PC.
  • Other languages exist, but most need a different board (MicroPython) or a computer in the loop (Firmata with Python or JavaScript).
C++11
language standard (gnu++11)
2 bytes
size of int on the Uno
4 bytes
size of double on the Uno
setup + loop
the two functions every sketch needs

What the Arduino software does to your sketch

You write setup() and loop(). You never write main(), because the Arduino core already contains one. In the core for AVR boards (version 1.8.8), main() calls setup() once and then calls loop() forever. That is the whole “Arduino language” structure.

Before compiling, the tool chain also joins all .ino tabs into one file, adds #include <Arduino.h>, and generates function prototypes so you can call a function before the place where you define it. After that it is an ordinary C++ build.

The compiler settings for an Uno

We read these from the Uno board package and compiled test sketches with them. They are the defaults the IDE uses unless you change them.

Setting Value on an Arduino Uno What it means for you
Compiler avr-gcc / avr-g++ 7.3.0 A GNU compiler, the same family used for PC programs.
C++ standard -std=gnu++11 C++11 features such as auto, nullptr and range-based for loops work. Features added in C++14 and C++17 are not guaranteed.
C standard -std=gnu11 Plain .c files in the sketch folder compile as C11.
Exceptions -fno-exceptions try, catch and throw are not usable. Check return values instead.
Optimisation -Os The compiler optimises for small code, because the Uno has 32 KB of flash.
Link-time optimisation -flto Unused functions are removed across files, which keeps sketches small.
Static initialisation -fno-threadsafe-statics There are no threads on an Uno, so function-local statics skip the locking code.
Sizes differ from a PC. On the Uno the compiler reports int as 2 bytes (range -32768 to 32767) and double as 4 bytes, the same as float. Use long for values above 32767, such as milliseconds from millis(), and do not expect extra precision from double.

Is it C or C++?

It is C++. The compiler is run in C++ mode, so every sketch must be valid C++. Most beginner sketches look like C because they use only functions and variables, which both languages share. The moment you use a class, such as Serial, Servo or LiquidCrystal, you are using C++. Serial.println() is a method call on an object, which plain C does not have.

So “Arduino language” is not a separate language. It is C++ plus the Arduino core library and the build steps above.

Try it: C++ features that work

This sketch uses a template function and a small class that blinks the on-board LED without delay(). It compiles for an Uno and uses 2,212 bytes of flash (6 per cent) with the toolchain above.

// duino4projects.com
// A C++ class and a template in a sketch: both compile for the Uno.
template <typename T>
T biggest(T a, T b) { return a > b ? a : b; }

class Blinker {
  public:
    Blinker(uint8_t pin, unsigned long period) : pin_(pin), period_(period), last_(0), on_(false) {}
    void begin() { pinMode(pin_, OUTPUT); }
    void update() {
      if (millis() - last_ >= period_) {
        last_ = millis();
        on_ = !on_;
        digitalWrite(pin_, on_);
      }
    }
  private:
    uint8_t pin_;
    unsigned long period_, last_;
    bool on_;
};

Blinker led(LED_BUILTIN, 500);

void setup() {
  led.begin();
  Serial.begin(9600);
  Serial.println(biggest(3, 7));
  Serial.println(biggest(2.5, 1.5));
}
void loop() { led.update(); }

Open the serial monitor at 9600 baud to see 7 and 2.50. The LED blinks every 500 ms because the class checks millis() instead of blocking.

Mixing in plain C

Put a file ending in .c in the sketch folder and the Arduino tool chain compiles it with the C compiler. Call it from the .ino file through extern "C", so the C++ compiler does not change the function name. We built this pair for the Uno: helper.c holds int add_in_c(int a, int b) { return a + b; } and the sketch calls add_in_c(2, 3).

// duino4projects.com
extern "C" int add_in_c(int a, int b);
void setup() { Serial.begin(9600); Serial.println(add_in_c(2, 3)); }
void loop() {}

What does not work on an Uno

The C++ standard library headers such as <vector>, <string> and <iostream> are not part of the Uno core. We tried #include <vector> and the build stopped with “compilation terminated” because the header is not found. Use fixed-size arrays, the Arduino String class (carefully, it uses heap memory), or a small library written for microcontrollers. Some libraries ported to AVR, such as ArduinoSTL, add parts of the standard library, at a cost in memory.

Watch the memory. The Uno has 2,048 bytes of RAM. A sketch that builds long String objects in loop() can fragment the heap and misbehave after hours of running. Prefer char arrays and the F() macro for fixed text.

Other languages and where they fit

C++ is the default, but not the only choice. The table separates what runs on the board from what runs on your computer.

Language Runs where Works with an Uno? Notes
C++ (Arduino IDE, arduino-cli, PlatformIO) On the board Yes The normal route. Everything on this page.
C On the board Yes Add .c files to the sketch, or write the whole program without the Arduino core.
MicroPython On the board No Arduino lists it for boards such as the Nano ESP32, Nano RP2040 Connect, Nano 33 BLE, Portenta H7 and GIGA R1 WiFi. Check Arduino’s board list for the current set.
Go (TinyGo) On the board Yes, small programs TinyGo lists the Uno, flashed with avrdude. Memory is tight, and some standard packages are too big.
Python or JavaScript with Firmata On your computer Yes The board runs a standard Firmata sketch and your computer sends commands over USB (for example with pyFirmata or Johnny-Five). The program stops when the computer disconnects.

Pick C++ when the project must run on its own from a battery or a power supply. Pick Firmata when you are learning programming in Python or JavaScript and the computer stays connected.

Operators you will use

The operators are the same as in C and C++. The ones that matter most in sketches:

Group Operators Typical use in a sketch
Arithmetic + - * / % int half = reading / 2; and x % 10 for the last digit
Comparison == != < > <= >= if (digitalRead(2) == LOW)
Logical && || ! if (hot && fanOff)
Bitwise & | ^ ~ << >> analogRead(A0) >> 2 turns a 10-bit reading into 8 bits
Compound assignment += -= *= /= |= &= count += 1;
Conditional (ternary) ?: level = hot ? HIGH : LOW;
One equals sign versus two. if (x = 3) assigns 3 to x and is always true. Use == to compare.

Common mistakes

Problem Likely cause Fix
“was not declared in this scope” A name is misspelt or written with the wrong capital letters C++ is case sensitive: digitalwrite is not digitalWrite.
“expected ‘;’ before …” A semicolon is missing on the line above Look at the line before the one the error names.
Header file not found The library is not installed, or the header is a PC-only one such as <vector> Install the library in the Library Manager, or avoid standard-library headers on an Uno.
Maths gives odd results Integer overflow: int holds only up to 32767 Use long or unsigned long, and write constants like 60000UL.

Project variants: Arduino programming guides

Related projects: other languages and tools

Quick answers

Is Arduino code C or C++?
C++. The build runs the C++ compiler with the standard set to GNU C++11. Simple sketches look like C because they only use functions and variables.
Do I need to learn C++ classes to use Arduino?
No. You can use classes that others wrote, such as Serial and Servo, without writing one. Writing your own becomes useful when a sketch grows past a few hundred lines.
Why does my sketch not need a main() function?
The Arduino core contains it. It calls setup() once and then loop() forever.
Can I use Python on an Arduino Uno?
Not on the board itself. You can drive an Uno from Python on your computer through Firmata, or use a board that supports MicroPython.
Which C++ version does the Uno use?
C++11, selected with -std=gnu++11 in the AVR core 1.8.8. Newer boards use other cores with other settings.

Check your own build

To see what your own setup uses, enable verbose output in the IDE (File, Preferences, “Show verbose output during: compilation”), compile, and look for the -std= option in the long avr-g++ line. If you use arduino-cli, run arduino-cli compile --verbose. The value tells you which C++ standard that board package selects.

Project resources and downloads

Share this project
X
LinkedIn
Reddit
WhatsApp

Quick Solutions to Questions related to theArduino Language Overview:

  • What language does Arduino natively use?
    Arduino natively uses a simplified C/C++ dialect compiled with GCC.
  • Can I write pure C for Arduino?
    Yes, you can write pure C code for Arduino using standard C syntax.
  • Does Arduino support full C++ features?
    Yes, Arduino can support full C++ (C++11/14/17), including classes, inheritance, and templates.
  • Can I program Arduino with Python?
    Yes, Python can be used with Arduino via the pyFirmata library.
  • How can I control Arduino from JavaScript?
    You can control Arduino from JavaScript using Firmata and Johnny-Five on Node.js.
  • Are there visual programming options for Arduino?
    Yes, Blockly and MakeCode provide block-based visual programming that compiles to Arduino code.
  • What common operators does Arduino use?
    Arduino uses standard C/C++ operators: arithmetic, assignment, comparison, logical, bitwise, and the ternary operator.
  • Do Arduino projects rely on libraries?
    Yes, Arduino relies heavily on an extensive library ecosystem like LiquidCrystal, Wire, SPI, and many more.
  • Is Arduino more C or C++?
    Arduino is a hybrid: it resembles C in style but is built on C++ and supports C++ features.
  • What language trends might affect Arduino?
    Potential trends include Rust, WebAssembly, expanded JavaScript/CircuitPython use, and new visual editors.
Scroll to Top