Xbox Controller

Python code and building instructions for the LEGO Technic Audi RS Q e-tron (42160).

Xbox Controller

Control the Technic Audi RS Q e-tron with the Xbox Controller.


In this project we’ll show you how to control the Audi RS Q e-tron with the Xbox Controller, using either block programming or Python.

Be sure to check out the documentation in the Pybricks app for instructions to pair the controller with the hub.

Note: This is brand a new feature. Try it with Pybricks beta!

Block Program

You can easily code this with the new block coding feature. Just drag and drop the blocks as shown below, or download the ready-made project here. In Pybricks, just go to the file menu and click the “Import a file” icon to open it.

  Download block program

Xbox Block Program

Python Program

from pybricks.iodevices import XboxController
from pybricks.parameters import Direction, Port
from pybricks.pupdevices import Motor
from pybricks.robotics import Car

# Set up all devices.
front = Motor(Port.A, Direction.CLOCKWISE)
rear = Motor(Port.B, Direction.CLOCKWISE)
steer = Motor(Port.D, Direction.CLOCKWISE)
car = Car(steer, [front, rear])
controller = XboxController()


# The main program starts here.
while True:

    # Drive using the trigger inputs.
    brake, acceleration = controller.triggers()
    car.drive_power(acceleration - brake)

    # Steer with the left joystick.
    horizontal, vertical = controller.joystick_left()
    car.steer(horizontal)


This project was submitted by The Pybricks Team.