Arduino C Programming: What the Language Actually Is

How-to basics · Updated November 22, 2026

Yes, you can write C-style code for Arduino, but the usual Arduino sketch is compiled as C++, not as strict C. The two languages share much of their basic syntax, so familiar C skills transfer well; Arduino’s standard functions and many libraries, however, are designed to be used from C++.

What people mean by Arduino C

When people ask about Arduino C, they often mean one of three things: using C-like syntax in an Arduino sketch, programming a board with the Arduino framework, or writing a program in the C language specifically. Those are related, but they are not identical. The Arduino environment makes it possible to get started with familiar constructs such as variables, functions, loops, conditionals, and arrays, while its standard sketch workflow uses a C++ compiler.

This distinction matters most when a project uses C++ features, a third-party library, or code written for a different microcontroller platform. A simple sketch may look almost exactly like introductory C. A larger one may rely on classes, templates, or C++ library interfaces that strict C compilers do not understand.

Why Arduino sketches use C++

The Arduino programming environment is built around C++ because it can support both low-level control and higher-level structures for organizing code. The Arduino core provides functions such as pinMode(), digitalWrite(), and analogRead(), while libraries can offer objects and methods for devices such as displays, sensors, and communication modules. This makes hardware features easier to package and reuse.

C++ also includes most of the familiar syntax used in C programs: declarations, arithmetic, if statements, loops, pointers, and functions. That overlap is why a beginner may reasonably describe an Arduino sketch as C, even though the compiler treats the sketch as C++. The difference becomes visible when using features that are valid in one language but not the other.

Arduino is an ecosystem, not one particular chip or compiler. The board model and its software platform determine the processor, available memory, core functions, and compiler toolchain. Consequently, exact C++ language support and hardware details vary across boards. Check the documentation for the particular board when a project depends on a specific language feature or peripheral.

How an Arduino sketch is compiled

In the common Arduino IDE workflow, the main sketch file has an .ino extension. The build process prepares that sketch as C++ and compiles it with the board’s core and selected libraries. The IDE handles some setup automatically, including providing the Arduino declarations and generating function prototypes in many ordinary sketches. This convenience can make an Arduino sketch look less like a conventional C++ program.

Other source files in a project can have different roles. A .cpp file is compiled as C++, while a .c file is compiled as C by compatible Arduino build systems. The exact project layout and build behavior can depend on the IDE, command-line tools, and board platform. If a sketch is split into several files, follow the current instructions for the toolchain being used rather than assuming every desktop C project can be copied over unchanged.

Compilation is only one part of making code run. The program must also be linked with the selected board’s core and libraries, fit the board’s memory limits, and use hardware interfaces that the board actually provides. A program that compiles for one Arduino-compatible board may need changes for another.

A basic Arduino example

This sketch repeatedly turns the board’s built-in LED on and off, with a half-second pause between changes:

const int ledPin = LED_BUILTIN;

void setup() {
  pinMode(ledPin, OUTPUT);
}

void loop() {
  digitalWrite(ledPin, HIGH);
  delay(500);
  digitalWrite(ledPin, LOW);
  delay(500);
}

The code uses ordinary C-like declarations, a constant, functions, and braces. Its two special entry points are part of the Arduino framework: setup() runs once after startup, and loop() runs repeatedly. In a typical standalone C or C++ desktop program, execution instead begins at main(). Arduino’s build environment supplies the framework structure that calls the sketch functions.

LED_BUILTIN identifies the built-in LED pin for boards that define it, so the actual pin is not necessarily the same on every model. The delay argument is in milliseconds. A delay is suitable for a small demonstration, but it pauses the sketch’s normal flow; projects that need to monitor several inputs or perform timely tasks often use a non-blocking timing approach instead.

What C skills transfer, and what does not

Most introductory C topics are useful: types, expressions, conditions, loops, functions, arrays, and the basics of pointers. Those skills help when reading Arduino examples and understanding how values move between a program and a device. The hardware-oriented functions are additional APIs, not replacements for the language itself.

Strict C does not include C++ classes, references, function overloading, templates, or namespaces. Arduino libraries commonly use C++ classes, so a library example may declare an object and call methods on it. For instance, a display library could expose a display object with initialization and drawing methods. That style will not compile as strict C without a C-compatible interface or a different library.

Conversely, C++ accepts much ordinary C-style code, but the languages are not interchangeable in every detail. Some constructs permitted in C are treated differently or are invalid in C++, and compiler settings can affect accepted features. If porting older C code, compile it in the intended language and address errors rather than assuming that similar-looking syntax guarantees compatibility.

Can you write pure C for an Arduino board?

It is possible to use C source code in projects targeting many Arduino-supported boards, provided the board platform’s build system supports the source file and the code can work with the available hardware and runtime. A practical approach is to put self-contained, portable logic in a C source file and keep board-specific setup and Arduino API calls in C++ files. This can be useful when sharing an algorithm with another C project.

The boundary between C and C++ needs care. C++ code that calls a function compiled from C generally needs a declaration with C linkage, commonly written using an extern "C" block in a header that may be included by C++ code. A C compiler cannot parse that C++ syntax, so shared headers often use conditional declarations. The project also needs compatible function declarations and types on both sides.

Using a C file does not automatically make the whole sketch a pure-C application. The Arduino core and many libraries are C++, and a mixed project still needs the appropriate C++ build and linking steps. If the goal is to use a board without the Arduino framework, a different embedded toolchain may be more suitable, but that means taking responsibility for startup code, peripheral configuration, and other platform details.

Choosing between Arduino C++ and another approach

For a first project, use the standard Arduino sketch workflow and learn the relevant C-like fundamentals alongside the board APIs. It has a large collection of examples and libraries, and the framework removes much of the setup needed to begin reading pins, controlling outputs, or communicating with common modules.

Choose C++ features when they help organize a project or when a required Arduino library uses them. Keep code simple when a small function or a few variables are clearer. Use separate C modules when portability or an existing C codebase is a real requirement, not merely because the phrase Arduino C sounds like a different mode in the IDE.

A different microcontroller framework can be worth considering when the project requires a particular development workflow, peripheral feature, performance level, or toolchain. Compare support for the exact board, libraries, debugging tools, and learning resources before switching. A language choice alone does not determine whether a project can control a device; the platform’s drivers and hardware support matter too.

Common errors and practical limits

Beginners often hit errors that appear to be language problems but come from the board setup or project structure. Check the selected board and port, spelling and capitalization, library installation, and whether a function has been declared before use in a context where the build process cannot generate a prototype. Read the first meaningful compiler error, since later messages can be consequences of an earlier typo or missing declaration.

  • Using a C++ library from C: A C file cannot directly use C++ classes or parse C++ headers. Put the interface behind compatible C functions or use the library from a C++ file.
  • Assuming all boards behave alike: Pin names, voltage levels, memory, and peripheral support vary. Check the board’s official pinout and specifications.
  • Running out of memory: Small microcontrollers have limited RAM and program storage compared with a computer. Large buffers, copied text, and heavy libraries can exceed the available capacity.
  • Blocking the program unintentionally: Long delays can prevent a sketch from promptly checking buttons, sensors, or communication. Use timing based on elapsed time when the program needs to do several things responsively.

Compiler messages are useful, but they do not identify every hardware mistake. Code can compile and still use the wrong pin, an unsupported feature, or an incorrect electrical connection. Test changes in small steps and consult documentation for the exact board and component.

Electrical safety and board protection

Programming does not make a board tolerant of incorrect wiring. GPIO pins have voltage and current limits that differ by board, and a pin is not a general-purpose power supply for motors, relays, or other demanding loads. Check the manufacturer’s specifications before connecting external circuits. Use an appropriate driver circuit and power source for loads that exceed what a pin can safely control.

Disconnect power before changing wiring when practical, avoid short circuits, and take particular care with batteries and mains-powered equipment. A basic LED circuit needs a suitable current-limiting resistor unless the board or module already includes one. Follow the component and board documentation; do not infer safe limits from an example made for a different model.

Frequently Asked Questions

Is Arduino C the same as C?
Not exactly. Arduino sketches in the standard workflow are compiled as C++, although much of their basic syntax resembles C. Strict C code can be used in suitable project files, but it cannot directly use C++-only features or APIs.

Do I need to learn C++ to use Arduino?
You can begin with basic programming concepts and Arduino examples without mastering all of C++. As projects use more libraries or larger code structures, understanding C++ basics becomes helpful because the usual sketch environment compiles sketches as C++.

Can I upload a C program directly from the Arduino IDE?
The usual sketch workflow expects an Arduino sketch and builds it with the selected board platform. Some project setups can compile C source files, but a standalone C program may need an appropriate entry point, startup code, hardware support, and build configuration. Check the chosen platform’s documentation.

Why does Arduino code have setup() and loop() instead of main()?
The Arduino framework provides the program structure and calls setup() once, then calls loop() repeatedly. This is why a basic sketch does not normally define its own main().

Can I use C libraries with an Arduino sketch?
Often, if the library is suitable for the board and its build system. A C library may need a compatible header and C-linkage declarations when called from C++ code. Check its dependencies, supported platforms, and memory requirements before using it.

Related

Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.

More in How-to basics

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.