When starting out with Arduino there can be a lot to learn: Programming, circuits, how to use the IDE, and the feeling of getting stuck when something isn’t working right even if you’ve followed all the instructions. I’ve been there, and I’ve grown a lot as a programmer and electronics engineer since. I put together this guide on how much programming knowledge is needed for Arduino to put your mind at ease and to give you some resources to get started with.
A basic understanding of programming is required to build projects with Arduino. This typically includes:
- How to import libraries, and what defined constants are
- Variables, and what their types are
- Control (if-else, loops, functions)
- Equations and bit-wise operators
With the above beginner to intermediate knowledge, you’ll be able to understand most Arduino projects and start to design your own. If you’re looking to go further, more advanced knowledge can include how memory is allocated and addressed; the use of timers, interrupts, and callbacks; and how to work with protocols and abstract types.
A great place to start learning Arduino programming is to think of a project you would like to achieve, and then piece it together from example code and reference material available on the internet. I personally start every project by modifying one of the built in examples, they’re a really valuable resource.
In this guide I’ve looked at: What programming languages to learn for Arduino; how to learn programming for Arduino; useful resources for programming with Arduino; and how long it typically takes to learn Arduino.
Which programming language to learn for Arduino
As a general rule, the C language is the one to learn when starting with programming Arduino. While the official Arduino IDE supports C++, most people getting started with Arduino will not use the extra features this language offers over C. Arduino can also be programmed with other languages, such as Lisp and Python, however these can be harder to set up.
I’ve found a basic understanding of C is required to work with Arduino, so that’s the best place to start. While there are other languages available for Arduino, they can be more difficult to set up and program; some Arduino boards do not even support other languages.
The table below outlines the languages I’ve found that can be used to program Arduino:
|C and C++||Native support||Can be difficult to learn, can be harder to find bugs|
|Rust||Better memory management than C||Difficult to setup and use on Arduino|
|Go||Powerful language, supported by Google||Not many examples, seems difficult to setup|
|Python (Micro-python)||Easy to learn, easy to find bugs||Only supports a few Arduino boards|
|Forth||Strong support for multi-tasking||Requires a change in bootloader (no longer able to program in C) and only supports more powerful boards|
|Lisp (uLisp)||Alternative way of expressing programs||Requires being attached to a computer|
Technically Arduino uses a language very similar to C++, but anything you write for the Arduino in C is valid and can be compiled via the Arduino IDE. For the simple projects I tend to work with, I haven’t found a feature of C++ that I’ve absolutely needed to use.
Uploading a simple C program to Arduino can be quite easy, I wrote a step-by-step guide on how to that here: chipwired.com/uploading-code-arduino.
Python can only be used to standalone program the Arduino Due. It is also possible to code in Python on some Arduino MKR family boards, however this relies on complex third party software. It is only possible to interact with other Arduino boards by connecting a serial link to a computer running Python, and writing the code on that computer. Check out this project for setting up Python to run on an Arduino Due.
Rust is a close alternative for programming any Arduino board. Libraries of code have been written to work with the processors at the heart of Arduino boards. Rust is not a complete replacement for Arduino C/C++ unfortunately as it seems many hardware peripherals (e.g. WiFi) don’t have libraries yet. While I can imagine it’s possible to use Rust to work with these peripherals (by controlling the pins directly), it would be quite a difficult task to do.
The Go language can be used on Arduino. Go supports Arduino using its TinyGo compiler and is capable of using most of the functions on an Arduino board. Some peripherals, such as WiFi and Bluetooth appear difficult to work with at this stage. There are not many tutorials or examples available on how to work with Go and Arduino. An example project on using Go on Arduino can be found here.
Forth can be used to program Arduino after loading a required boot loader. Only Arduino boards with more than 12 kilobytes of flash memory are supported. Full details are available on their website.
Lisp on Arduino is similar to Python, in that you need a connected computer for it to work. I find it’s also a difficult language to understand, so I haven’t looked much further into it. The paradigm it represents (functional programming) is an interesting way to think about how to program processors though.
How to learn programming for Arduino
To learn programming for an Arduino:
- Understand the basics by reading a book, watching YouTube videos, or taking a course
- Learn by doing, actually program an Arduino and run example code on your own Arduino
- Sketch out programs by hand, draw block diagrams or flow charts to describe how programs are working
- Try your own projects, write code to implement your own ideas
See below for some good resources I’ve found for learning Arduino.
My biggest tip from years of programming is: Start with working example code and then modify it to your needs.
I also found most projects fit into one of these categories (so if you learn an example of each of these, you’re doing pretty well):
- Read from a sensor; connect to a computer (Bluetooth, WiFi or cable); report that data for analysis
- Operate a motor, display or other hardware based on data received from a sensor or a computer
A real benefit of doing your own code and projects is that when something breaks you get to figure out why and fix it. This is how I learnt a lot about coding and how Arduino work – by trying to fix it when something went wrong.
If something goes wrong, my three steps to fixing it (and learning along the way) are:
- Google the problem, try a few different ways of describing it, likely others are having similar problems
- Read reference material, such as the Arduino Reference, library descriptions, API documentation, even data sheets
- Post on forums and ask others for help
I try to avoid posting on forums because when I’m caught up in a problem I like to figure out a solution quickly.
If you’re looking to purchase an Arduino, check out my guide here to the costs involved: chipwired.com/arduino-cost-guide/
Resources for learning Arduino programming
I found the following YouTube videos helpful in learning Arduino programming:
- Arduino Programming in an hour
- Step-by-step Arduino tutorial for beginners (a few hours learning here)
The following example projects are a good place to get started (not as many components or complicated circuits required):
Starter kits include all the instructions and hardware (including the Arduino board) to build a bunch of projects, I wrote on a guide on the best value Arduino boards and starter kits here.
The Arduino website has some great tutorials as well:
These books also offer good details on Arduino programming:
I’ve also seen some courses for Arduino programming (though I haven’t tried these so don’t know if they’re good):
Personally I got my start learning programming when I was young. Without example projects to play with, or a direction in my learning, it took me a few years to get to the point where I could program Arduino. I first learnt to program C; then I learnt how to program a PIC microcontroller, then I applied these skills to Arduino.
How long it takes to learn Arduino programming
Basic Arduino programming can be learnt in 4-6 hours, based on a survey of the available resources. In this time, it is possible to learn how to program an Arduino to read a sensor and return that data to a computer. More advanced Arduino programming can be learnt by experimenting with shields, APIs, and other hardware; this takes a longer amount of time depending on how much depth of knowledge is required.
Chris spent years in university learning about programming and electronics. He enjoys sharing that knowledge in the hope that it doesn’t take you that much time to learn.