Python programming
Learn how to program your eXperiBot in Python.

To program eXperiBot in Python, you will need the free development environment Visual Studio Code. eXperiBot connects directly to the development environment and is controlled using the eXperiBot extension for Visual Studio Code—so you don’t need a separate app.
If you’ve already worked with the eXperiBot Blockly app, you will quickly find your way around the eXperiBot extension for Visual Studio Code.
Some parts of the documentation refer to “eXperiBot apps.” This also refers to the Visual Studio Code extension described here.
MicroPython
eXperiBot is programmed using MicroPython—a lightweight version of Python developed specifically for microcontrollers such as the one in the Powerbrain. MicroPython uses the same syntax and includes almost all of Python 3’s functionality but is optimized for use on small devices. All the basic functions needed to learn how to program in Python are fully available.
Requirements
To program your eXperiBot in Python, you will need:
a PC running Windows, macOS, or Linux
the Visual Studio Code development environment
the eXperiBot extension for Visual Studio Code
To set up Visual Studio Code and the eXperiBot extension, you must have permission to install new programs on your device.
System requirements for using the eXperiBot extension
To use the eXperiBot extension, you need Visual Studio Code 1.100.0 or later. Windows systems with ARM processors (ARM64 architecture) and Linux systems with 32-bit architecture are not currently supported.
Please also note the general system requirements for using Visual Studio Code.
Set up Visual Studio Code
There are several ways to download Visual Studio Code:
As an installer from the Visual Studio Code website
As an app from the Microsoft Store
Install the eXperiBot extension
Launch Visual Studio Code. In the left sidebar of Visual Studio Code, click the “Extensions” icon.

In the sidebar that opens, search for “experibot”, select the eXperiBot extension from Cornelsen, and click “Install”.
To ensure you receive future updates with improvements and troubleshooting, you should keep “Auto Update” enabled.

During installation, you may be asked to trust extensions of the publisher Cornelsen.

Manual Installation
If you are unable to install Visual Studio Code extensions from the Marketplace in your environment, you can download the eXperiBot extension here as a VSIX package.
If you install the eXperiBot extension as a VSIX package, you will not receive automatic updates with improvements and troubleshooting.
Launch the eXperiBot extension
After installation, you will find the eXperiBot extension as an icon in the left sidebar. Click the icon to open the extension.
If the eXperiBot extension does not appear in the sidebar, right-click in the empty area of the sidebar and check the “eXperiBot” box in the submenu.
You can now use the extension and start coding.
Enable IntelliSense
To take full advantage of all the features of the eXperiBot extension, we recommend enabling IntelliSense.
IntelliSense includes many useful features for programming in Python, such as automatic code completion, syntax error highlighting, and quick access to the documentation when using the eXperiBot Python API. The Python extension for Visual Studio Code provided by Microsoft will be installed during activation if it is not already present.
To enable IntelliSense, click “Enable IntelliSense”.

If you’re having trouble enabling IntelliSense or if the activation fails, you can find more information in the Help and troubleshooting section.
Get Help with Visual Studio Code
If you need help using Visual Studio Code, please refer to the Visual Studio Code documentation.
Connect eXperiBot
Here’s how to connect your eXperiBot to Visual Studio Code:

Turn on your eXperiBot by pressing and holding the play button on the Powerbrain’s control panel.
Click the “Connect” button in the eXperiBot extension and follow the instructions.
Once a connection has been established, the Powerbrain’s status LED will light up blue.
When you connect your eXperiBot for the first time, a system dialog may appear asking you to allow Visual Studio Code to use Bluetooth.
Program eXperiBot
Once you’ve connected your eXperiBot, you’re ready to go.
If you don’t have a Python program open in Visual Studio Code yet, your eXperiBot will run the last program you uploaded when you click “Run program.”

To get started with programming, you must first create a new Python program or open an existing one.
Create a new program
Click “New Python program” to create a new Python program.

You will now be prompted to specify a name and location for your program. The program will then open in Visual Studio Code for editing, and the program’s name will appear in the eXperiBot extension window.

Your new Python program is already pre-populated with code so you can focus entirely on bringing your ideas to life. The pre-populated code includes importing the experibot module and initializing the Powerbrain and all modules connected to your eXperiBot.
If you’d rather start with a blank file, you can disable the auto-fill feature in the eXperiBot extension settings.
Save and open programs
You can save and open programs using the file menu in Visual Studio Code. Opening and saving files works the same way as in all standard code editors.
If you are already familiar with tools like Git, you can also use them in Visual Studio Code to manage and version control your programs.
Use workspaces in Visual Studio Code
We recommend using workspaces in Visual Studio Code. They allow you to group multiple folders or projects into a single view and manage them together. When working with AI agents, using workspaces also offers the advantage that agents can access all files within the workspace without having to request permission for each file.
Export programs from the eXperiBot Blockly app
If you have written a block-based program in the eXperiBot Blockly app and want to continue developing it in Python, you can export it as a Python program and then open it in Visual Studio Code.
To do this, launch the eXperiBot Blockly app and open the project you want to export. Now click the “Show Python code” button on the right side of the block editor.

The Python code view opens.

Here, you can export the Python code as a Python file by clicking the “Export” button (or ‘Share’ on mobile devices). You can then open this file in Visual Studio Code.
Alternatively, you can copy the Python code by clicking the “Copy” button and then paste it into an already open Python program in Visual Studio Code.
It is not possible to transfer a Python program from Visual Studio Code back to the eXperiBot Blockly app.
Manage eXperiBot
Once Visual Studio Code is connected to your eXperiBot, you can manage your eXperiBot. The corresponding screen displays all the important information about your eXperiBot.

Manage eXperiBot
This button opens the dialog that allows you to manage your eXperiBot. The designation “A42” displayed on the button varies from eXperiBot to eXperiBot.
Dialog for managing your eXperiBot
In this dialog you will find important information about your eXperiBot: name, battery charge level, version, and an overview of all connected modules.
LED colors of the connected modules
Here you can see the LED colors of the modules connected to your eXperiBot. They correspond to the color of the status LED of the respective physical module. You can change them at any time here. You can find out when this is helpful in the section Selecting an LED color.
Disconnect
Here you can disconnect from your eXperiBot. Alternatively, you can also turn off the eXperiBot or close Visual Studio Code.
Help
If a module is not displayed despite an existing connection to the eXperiBot, you can get help by clicking this button.
If a module is not listed in connected modules even though it is connected to the eXperiBot, try disconnecting the module from the eXperiBot and reconnecting it. If the module still does not appear, you can find more information in the Help and troubleshooting section.
Selecting an LED color
Please read the section Distinguishing between identical modules first so that you understand how and why modules of the same type are distinguished from each other.
When initializing eXperiBot modules, you can specify which module to use in the program code.
To do this, you must pass the module’s LED color as a parameter to the function:
multisensor_blue = Multisensor(LedColor.BLUE)You can change the LED color of your modules at any time. To learn how, see the Manage eXperiBot section in the eXperiBot section.
If only one module of a given type is connected, you can simply omit the LED color parameter.
motor = Motor()
In this case, the Powerbrain uses the first module of that type.
Settings
In the settings, you’ll find options that let you customize how the eXperiBot Extension for Visual Studio Code behaves. You can open the settings by clicking the “Settings” button.

The following settings are available:
New Python Program: Prefill Content
auto: New Python programs already include all necessary imports and initializations for connected eXperiBot modules.
none: New Python programs are empty.
Web Content: Open In
editor: Web content opened by the eXperiBot extension is opened within Visual Studio Code.
browser: Web content opened by the eXperiBot extension is opened in the operating system’s default web browser.
Commands and shortcuts
The eXperiBot extension adds several commands to Visual Studio Code that can make your work easier.
You can view all eXperiBot commands by typing >experibot into the top search bar.

The following commands already have keyboard shortcuts assigned to them:
Create new Python program:
Strg + Nor⌘(Command)+ NToggle (run or stop) program:
F5
In Visual Studio Code’s settings, you can assign custom keyboard shortcuts to any command.
Since commands can also be used by AI agents, they can independently create new programs and run them on the eXperiBot. You can learn more about this in the section Program with AI Support.
Sequential and concurrent execution
As you write your program, you’ll notice that some commands have a wait parameter, which is set to true by default. It’s important to understand what this parameter means:
If wait = true, program execution is paused until the command has been executed by the eXperiBot. This is referred to as sequential execution.
If wait = false, program execution continues even while the command is being executed by the eXperiBot. We refer to this as concurrent execution. This allows your eXperiBot to perform different tasks at the same time: for example, your eXperiBot can move forward while simultaneously detecting objects with the Multisensor.
The documentation for each command explains in detail what these two execution modes mean.
In some commands, sequential execution is determined not by a wait parameter, but by passing a time parameter (e.g., duration). If this parameter is omitted, the command is executed concurrently.
For example, with the motor’s set_speed() command, you can omit the duration to allow the motor module’s axles to rotate until they receive another command or until the program terminates.
Please note that this behavior is not the same as “multithreading”, which refers to the parallel execution of multiple command chains. Your program will always execute linearly.
The following example illustrates this:
from experibot import *
powerbrain = Powerbrain()
motor = Motor()
multisensor = Multisensor()
motor.set_speed(50, 50)
while True:
if multisensor.detects_object():
powerbrain.terminate_program()
passThe motor module is instructed to move straight ahead using the set_speed() command. Then, a loop checks whether the Multisensor detects an object using the detects_object() function. If this is the case, the Powerbrain terminates the program using the terminate_program() command, and the eXperiBot comes to a stop. The motor therefore continues to run straight ahead while the program checks in an infinite loop to check if an object has been detected.
eXperiBot live data
In the eXperiBot live data view, you can view data from your eXperiBot in real time within the app, without having to run a program.
Once you’ve connected your eXperiBot, you can view the live data by clicking the “Show eXperiBot live data” button.

Once you’ve connected your eXperiBot to the app, you can access various data sources, depending on the modules connected to your eXperiBot. This allows you to check measurement values without running a program. Click the information button to view helpful details about the selected data source.
For each data source, there is a corresponding function in the eXperiBot Python API that can retrieve the respective values within a program.

By default, the data is updated every 100 milliseconds. The eXperiBot can transmit data from up to six data sources simultaneously. While the eXperiBot is running a program, live data is not available. If you close the live data view, data transmission stops automatically.
On older devices or in environments with poor Bluetooth signal, you may need to increase the refresh interval to ensure that data is updated regularly. You can adjust the refresh interval in the settings menu of the live data view.
Message log
In the message log, you can see all the messages that your eXperiBot outputs or has output while running a program. Once you have connected your eXperiBot, you can open the message log by clicking the “Show message log” button.

Since the log of the last program execution can also be read by AI agents, they can independently evaluate the content and analyze an error in the program. You can learn more about this in the section Program with AI support.
Output messages
You can output your own messages by calling the print() function. The following sample program shows various ways to use the print() function:
# Output a value
print("Hello world!")
# Output multiple values
print("I am eXperiBot.", "Who are you?")
# Output multiple values with a user defined separator
print(1, 2, 3, sep = " | ")
# Output all iterator values
values = [1, 2, 3]
print(*values)
# Output a formatted string
number = 42
print(f"My favorite number is {number}.")
print("My favorite number is {}.".format(number))
print(f"{number=}")
# Output a string with escape sequence
print("You said: \"Hi!\"")
# Output an empty line
print()
# Output a separator line
print("-" * 30)The sample program outputs the following messages:
Hello world!
I am eXperiBot. Who are you?
1 | 2 | 3
1,2,3
My favorite number is 42.
My favorite number is 42.
number=42
You said: "Hi!"
------------------------------If multiple print() commands are executed without a wait time, minor delays of approximately 30 milliseconds per execution may occur in the program’s flow for technical reasons.

By default, the message log opens automatically when the first message is printed. If you restart the program, a separator line is added to the message log so that you can always tell which messages are from the most recent run. The timestamps displayed with each message are, by default, relative to the time the program was started.
In the message log settings you can disable automatic opening if needed and also customize the time stamp format. You can access the message log settings via the gear icon.
Messages in the message log remain there until you manually clear it or close Visual Studio Code. For technical reasons, after a certain point the oldest message is automatically deleted when a new message arrives. You can export the contents of the message log as a text file at any time.
Error messages
If an error occurs while a program is running, the error message from Python is added to the message log, which helps you better understand and resolve the error.

Program with AI support
You can use AI agents to program your eXperiBot via Visual Studio Code’s built-in chat feature.
The eXperiBot extension provides an “experibot” skill for this purpose, which AI agents can use to understand the eXperiBot Python API, develop programs, and run them. The agent automatically uses this skill when you chat with it about topics related to robotics and the eXperiBot.

To learn how to use AI agents in Visual Studio Code, see the Visual Studio Code documentation: Build with agents in VS Code.
Please note that when working with AI agents, results can vary significantly depending on the language model used. We recommend using language models from Anthropic (Claude) and OpenAI (GPT).
GitHub Copilot
To take advantage of all of Visual Studio Code’s AI features, we recommend using GitHub Copilot. GitHub Copilot is a paid service, but it can also be used for free with limited resources.
Verified instructors and students can use GitHub Copilot in its entirety for free. For more information, see the GitHub documentation.
Possible programming errors
When programming eXperiBot, errors may occur that prevent the program from running. Here are some of the most common errors that can occur during programming:
Argument has an invalid type or value (
TypeError,ValueError)These errors can occur, among other things, when a value passed to a function does not meet the requirements of the respective parameter.
Division by zero (
ZeroDivisionError)Division by zero can occur unnoticed, for example, when variables are used whose value is set to zero during the course of the program—such as when processing an unhandled sensor value.
Recursion errors (
RecursionError)Recursion errors can occur when a function repeatedly calls itself and there is no suitable termination condition. To prevent the eXperiBot from freezing, the system detects this error and terminates program execution.
Memory errors (
MemoryError)Memory errors can occur during program execution if the program’s required memory becomes too large. This can happen, for example, when a particularly large number of elements are added to lists. Since the memory available to the program is not always the same for technical reasons, memory errors may occur slightly earlier or later on a case-by-case basis.
You can find a list of all error types in Python in the Python documentation.
eXperiBot-specific errors
Errors may also occur that are triggered by the eXperiBot itself. For example, if a required eXperiBot module suddenly becomes unreachable while the program is running, a ModuleNotRespondingError may occur. All eXperiBot-specific errors are documented in the Python API documentation.
eXperiBot Python API documentation
The eXperiBot Python API is the interface between your program and the eXperiBot. Its documentation provides a detailed description of all the classes and functions you need to program your eXperiBot using Python.