Skip main navigation

New offer! Get 30% off one whole year of Unlimited learning. Subscribe for just £249.99 £174.99. New subscribers only. T&Cs apply

Find out more

How to get started in programming for robotics

In this article, we introduce programming, the important languages, and how you can get started with tools like Arduino and Raspberry Pi.
An engineer programs a drone in the robotics lab
© The University of Sheffield

Programming is a key skill to develop for working in robotics. In this article, we’ll introduce programming, the important languages, and how you can get started with tools like Arduino and Raspberry Pi.

What is a computer program?

Robots process sensor data, perform cognition and plan actions using computer programs that are executed on a processor. Computer programs are essentially a set of instructions that operate on an input to produce an output.

Example: A face recognition program in a robot will:
1. take an image of a person as an input,
2. scan the image for a specific set of features,
3. compare these features to a library of known faces,
4. find a match, then
5. return the name of the person as an output.
The program will perform exactly these same set of instructions every time it executes.
Most programming languages are written in normal text, which is easy for humans to understand. Programs are then compiled into machine code for a processor to execute (or byte code, for a virtual machine to execute).

Programming languages

There are numerous programming languages available, e.g. C/C++, Java, Fortran, Python etc. The most popular language in robotics is probably C/C++ (C++ is an object-oriented successor to the C language). Python is also very popular due to its use in machine learning and also because it can be used to develop ROS packages – see below.
There are additional, important software tools used in robotics, in particular:
  • Robot Operating System (ROS) is a set of software libraries and tools that helps you build robot applications. You can also write your own programs for ROS e.g. in C/C++ or Python.
  • Matlab is used for data analysis and interfaces with ROS (also, Octave is a free, open-source equivalent to Matlab available here.)

C programming and the Arduino microcontroller

The C/C++ language is one of the most widely used programming languages in robotics. The Arduino microcontroller uses a programming language based on C and is a great way to learn the basics of this important language whilst doing hands-on robotics.
An Arduino MEGA 2560 microcontroller. The microcontroller is in fact just the large chip in the centre of the Arduino – this is the component that you program: high-level code that you write is compiled down to machine code that is embedded on this chip. The pins at the top and bottom are for connecting input devices, such as sensors, and output devices such as motors.
A basic Arduino (Uno) costs about EUR 19 and the program development environment can be downloaded for free from the Arduino website where you’ll also find many example projects and tutorials.

Python and the Raspberry Pi

Python is a useful language to learn as it is widely used in computer science and machine learning. Python is the language that is used with the Raspberry Pi. This makes it highly relevant to robotics because you can use a Raspberry Pi to control a robot.
The Raspberry Pi Foundation has developed a number of free online courses for learning how to use a Raspberry Pi in robotics. Check out their partner’s page for more information and links to the courses.
The Raspberry Pi 3, Model B. The Raspberry Pi is like a normal PC but much smaller. This Raspberry Pi 3 has a 1.2 GHz quad-core ARM processor, ethernet, wireless, Bluetooth, HDMI and 4 USB ports.

What are the differences between an Arduino and a Raspberry Pi?

The Arduino and Raspberry Pi are both useful for robotics projects but have some important differences.


An Arduino is a microcontroller, which is like a simple computer but which runs and loops a single program that you have written on a PC. This program is compiled and downloaded to the microcontroller as machine code. The Arduino is well suited to low-level robot control and has features like analogue-to-digital conversion for connecting analogue sensors.

Raspberry Pi

A Raspberry Pi (RPi) is just like a normal PC and so is more versatile than an Arduino but lacks features like analogue-to-digital conversion. The RPi runs a Linux operating system (usually Raspian). You can connect a keyboard, mouse and monitor to an RPi, along with peripherals like a camera – very useful for robotics. (Due to the fact that the RPi runs Linux you can also install ROS although it can be a bit tricky to set up.)

If you’d like to learn more about programing for robotics, check out the full online course from The University of Sheffield, below.

© The University of Sheffield
This article is from the free online

Building a Future with Robots

Created by
FutureLearn - Learning For Life

Reach your personal and professional goals

Unlock access to hundreds of expert online courses and degrees from top universities and educators to gain accredited qualifications and professional CV-building certificates.

Join over 18 million learners to launch, switch or build upon your career, all at your own pace, across a wide range of topic areas.

Start Learning now