Bluetooth-Controlled Car
A Bluetooth-controlled robotic car powered by Raspberry Pi Pico 2W with obstacle avoidance.
Author: Stiuj Emanuel-Ștefan
GitHub Project Link: https://github.com/UPB-PMRust-Students/proiect-emanuelstiuj
Description
This project is a Bluetooth-controlled car that can be operated using an Android application. The vehicle responds to directional commands such as forward, backward, left, and right, and can also stop on demand. An onboard obstacle detection system allows the car to avoid collisions without user input. In addition to movement, the car features LED indicators for visual signaling and a basic control system that manages motor speed and direction in real time based on incoming commands.
Motivation
This project was inspired by a strong interest in cars and remote-controlled systems. It provided an opportunity to better understand how various components, such as microcontrollers, motor drivers, sensors, and communication modules, interact in a real-world embedded system. Working on this allowed for both creative and technical exploration, combining hardware and software to build something functional, interactive, and fun.
Architecture
System Architecture
The system is built around a central microcontroller, the Raspberry Pi Pico 2W, which interfaces with multiple peripherals to enable wireless control and feedback:
- Bluetooth (HC-05 module): Connects to the Pico via UART for serial communication, receiving commands from an Android device over the Bluetooth Serial Port Profile (SPP). The HC-05 operates typically as a slave device, allowing the phone to initiate and send control data.
- Motor Driver (L298N): Receives PWM signals (for speed control) and GPIO signals (for direction control) from the Pico to drive DC motors. The L298N provides high-current output to the motors based on the Pico’s low-power signals.
- IR Sensor: Outputs digital signals to a GPIO pin on the Pico when detecting obstacles within its range, enabling proximity-based decision-making.
- LEDs: Controlled via GPIO pins to provide visual feedback on system states (e.g., power status, collision detection, or turning left/right).
- Power Supply (2x 18650 batteries): Supplies power to the L298N motor driver directly (typically at 7.4V) and to the Pico through a voltage regulator (e.g., 5V step-down converter) to ensure stable operation.
Flow of Control
- The Android device sends commands wirelessly to the HC-05 module via Bluetooth SPP.
- The HC-05 relays these commands to the Pico over UART, where they are interpreted by the firmware.
- The Pico processes the commands and generates PWM and GPIO signals to the L298N, controlling motor speed and direction.
- If the IR sensor detects an obstacle, it sends a digital signal to the Pico, which can override the received commands to stop or redirect the motors, preventing collisions.
- LEDs are optionally toggled via GPIO to provide visual feedback on system states (e.g., power status, collision detection, or turning left/right).
Log
Week 5 - 11 May
Week 12 - 18 May
Week 19 - 25 May
Hardware
- Raspberry Pi Pico 2W: Microcontroller handling communication, logic and motor control.
- HC-05 Bluetooth Module: Wireless interface for receiving remote control commands.
- L298N Motor Driver: Allows control of DC motors via GPIO and PWM.
- IR Obstacle Sensor: Detects objects in front of the car and sends digital feedback.
- LEDs + Resistors: Used as visual indicators.
- 2x DC Motors + Wheels: Provide mobility.
- Power Supply (2x 18650 Batteries): Delivers sufficient voltage and current.
- Chassis, Wires, Breadboard: Assembly and connectivity.
Schematics
Bill of Materials
Device | Usage | Price |
---|---|---|
Raspberry Pi Pico 2W (x2) | One microcontroller handles main control; the second is used for debugging | 80 RON |
HC-05 Bluetooth Module | Enables wireless communication with an Android app for remote control | 28 RON |
L298N Motor Driver | Drives two DC motors and also provides 5V output to power the Raspberry Pi Pico | 11 RON |
3-6V DC Motor with Wheel (x2) | Provides motion using gear-reduced DC motors | 30 RON |
IR Obstacle Sensor | Detects nearby objects to support autonomous navigation | 20 RON |
LED Headlights (x2) | Indicator lights for signaling | 1 RON |
18650 Li-ion Battery (x2) | Power supply (7.4V) | 40 RON |
Battery Holder (2x18650) | Holds two 18650 batteries in series for higher voltage output | 4 RON |
Switch | Used to turn the power supply on or off | 3 RON |
220Ω Resistors (x2) | Limits current for LEDs | 1 RON |
Breadboard 830p | Rapid prototyping and testing of circuit connections | 11 RON |
Male–Female Wires (set) | Connects modules to the Pico or to the breadboard | 5 RON |
Jumper Wires (set) | General-purpose wires for connecting components on the breadboard | 8 RON |
Male Header Pins (40x2) | For plugging Raspberry Pi Pico into breadboard | 2 RON |
Chassis | Main platform for mounting all components | 25 RON |
Support Wheel | Balances and stabilizes the rear of the car | 5 RON |
Total Estimated Cost: ~274 RON (excluding shipping).
Software
Library | Description | Usage |
---|---|---|
embassy | Asynchronous embedded framework in Rust | Core framework for async multitasking on the Pico 2W |
embassy-rp | RP23450-specific support for Embassy | Enables async support and peripheral access on Raspberry Pi Pico 2W (GPIO, PWM, UART, etc.) |
embedded-hal | Hardware Abstraction Layer | Standard traits for embedded peripherals |
embassy-time | Async timers and delays | Used for non-blocking delays and timeouts |
embassy-executor | Task executor for async Embassy | Runs async tasks in cooperative scheduling |
defmt | Logging for embedded Rust | Efficient debug output via probe |
panic-probe | Panic handler | Reports panics via probe in development |
L298N | Motor driver implementation | Speed and direction control |