The short genesis of the project: 2 years ago for my b-day I received Xbox one pad, this year (also b-day gift) I got Lego car and on Christmas- Raspberry Pi Zero W. So I decided to use all those gits, get some knowledge of electronics and create my first project.
Short video:
- Raspberry PI Zero W
- Xbox one pad
- Motor: N20-BT13
- TB6612FNG Dual Motor Driver Carrier
- Servo SG-90
- hc-sr04 distance sensor + holder
- LEGO - Technic First Responder (or any other)
- Power bank,
- 9v Battery,
- LED or buzzer,
- resistors (2x330 and 480 Ω)
- Cables and soldering iron
- Connecting Xbox pad to Raspberry This task is relatively easy as our PI Zero W have build in Bluetooth module, and new Xbox controller doesn’t require additional adapters. Unfortunately there is also one disadvantage, but about that, later on. Connection can be done with following commands in terminal:
echo 'options bluetooth disable_ertm=Y' | sudo tee -a /etc/modprobe.d/bluetooth.conf
ertn (Enhanced Re-Transmission Mode) is not well supported by Raspbian and can cause connection interuptions. Restart:
sudo reboot
Open Bluetooth agent and scan devices.
sudo bluetoothctl
scan on
All available devices will pop up on a list, you should be able to find your controller and check it’s MAC address. Then:
pair YOUR_MAC_ADDRESS
trust YOUR_MAC_ADDRESS
connect YOUR_MAC_ADDRESS
For communication between pad and Raspberry I used Joystick API. I know, there is xboxdrv available for Python, which works well, but it doesn’t support bard new Xbox controller 😊. So, let’s install this API:
sudo apt-get install joystick
And clone repository.
git clone https://github.com/Miker91/LegoPyCar
I know that attached schemas are tragic, but this is my first shoot. They will help you assemble the model. Fitting everything in such a small model is not a simple task but I'm sure you will manage :)
Some build tips:
- How servo works?
- How motor works?
Application can by run by:
cd LegoPyCar/
python3 main.py
- @Miker91 - Idea & Initial work
See also the list of contributors who participated in this project.
- References: https://gist.github.com/rdb/8864666 great code for use Joystick API