Skip to content

Program to control Lego car with Xbox controller

Notifications You must be signed in to change notification settings

Miker91/LegoPyCar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project logo

Lego PyCar

Status License


📝 Table of Contents

🧐 About

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:

Lego PyCar

🏁 Getting Started

Prerequisites

  • 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

Installing

  1. 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

🔧 Build you CAR!!!

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?

Lego PyCar - Servo

  • How motor works?

Lego PyCar - Motor

🎈 Usage

Application can by run by:

cd LegoPyCar/
python3 main.py

✍️ Authors

See also the list of contributors who participated in this project.

🎉 Acknowledgements

About

Program to control Lego car with Xbox controller

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages