mirror of
https://github.com/pybricks/pybricks-projects.git
synced 2026-07-27 19:55:46 +00:00
sets: Add Audi Xbox example.
This commit is contained in:
@@ -10,6 +10,8 @@ video:
|
||||
youtube: "c0KVNdJlAkc"
|
||||
description: "Control the Technic Audi RS Q e-tron with the Powered Up Remote."
|
||||
code: "#program"
|
||||
building_instructions:
|
||||
external: https://www.lego.com/cdn/product-assets/product.bi.core.pdf/6508358.pdf
|
||||
---
|
||||
|
||||
In this project we'll show you how to control the Audi RS Q e-tron with the Powered Up remote.
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 219 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 145 KiB |
File diff suppressed because one or more lines are too long
@@ -0,0 +1,23 @@
|
||||
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)
|
||||
@@ -0,0 +1,40 @@
|
||||
---
|
||||
title: "Xbox Controller"
|
||||
maintainer:
|
||||
user: "pybricks"
|
||||
name: "The Pybricks Team"
|
||||
image:
|
||||
local: "./audi-xbox.jpg"
|
||||
description: "Control the Technic Audi RS Q e-tron with the Xbox Controller."
|
||||
code: "#python-program"
|
||||
building_instructions:
|
||||
external: https://www.lego.com/cdn/product-assets/product.bi.core.pdf/6508358.pdf
|
||||
video:
|
||||
youtube: "fxInp9cutNg"
|
||||
---
|
||||
|
||||
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](https://beta.pybricks.com/)!
|
||||
|
||||
# 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.
|
||||
|
||||
<a href="./audi_blocks.py" target="_blank" class="btn btn--primary"><i class="fas fa-puzzle-piece"></i> Download block program</a>
|
||||
|
||||

|
||||
|
||||
# Python Program
|
||||
|
||||
{% include copy-code.html %}
|
||||
```python
|
||||
{% include_relative audi_python.py %}
|
||||
```
|
||||
Reference in New Issue
Block a user