Skip main navigation

£199.99 £139.99 for one year of Unlimited learning. Offer ends on 28 February 2023 at 23:59 (UTC). 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

Our purpose is to transform access to education.

We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.

We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.

Learn more about how FutureLearn is transforming access to education