How to Make a Raspberry Pi Pico Bluetooth Control Car
by Shahbaz Hashmi Ansari in Circuits > Raspberry Pi
4150 Views, 22 Favorites, 0 Comments
How to Make a Raspberry Pi Pico Bluetooth Control Car
Greetings everyone, and welcome to my Instructables tutorial. Today, I'll guide you through the process of creating a Bluetooth-controlled car using Raspberry Pi Pico.
Project Overview:
In this project, we will utilize a Bluetooth module receiver to receive commands from mobile. Based on the received commands, the car will perform corresponding actions. For instance, pressing the forward button on the mobile will make the car move forward, and the opposite for the reverse.
I would like to extend my gratitude to PCBWay for their sponsorship in making this project possible.
Without further ado, let's dive into the project and get started!
Supplies
Below are the components required for making this Bluetooth-controlled car using Raspberry Pi Pico:
- Raspberry Pi Pico: https://bit.ly/3XydsgM
- L298N motor driver: https://bit.ly/46qH7Nb
- Bluetooth module: https://bit.ly/3XufP4e
- Gear motor: https://bit.ly/3cOLKX2
- Rubber wheel: https://bit.ly/3cOLKX2
- Battery holder: https://bit.ly/3cOLKX2
- Battery: https://bit.ly/3cOLKX2
Making of the Chassis:
Here is a step-by-step guide for making the Chassis:
- Cut a piece of cardboard to the dimensions of 10cm by 14cm to create the chassis.
- Obtain four-gear motors.
- Attach the motors to the cardboard using a hot glue gun.
- Wire the motors in a cross-word direction, as shown in the image above.
- Obtain four rubber wheels for the motors.
- Once these steps are completed, the chassis will be ready.
let's move to the next step...
Motor Driver and Motor Wiring:
- Begin by establishing a connection between the L298N Motor Driver and Motor.
- Attach the motor driver to the back side of the chassis using double-sided tape, as shown in the image.
- Connect the motor wires to the motor terminals of the motor driver.
and that's all you need to do for making the chassis functional.
How Can I Simplify My Circuit?
This can be done by using a PCB, I have many times used a custom-designed circuit board to give more professional touch. So I choose PCBWay to design and order the custom-designed PCB for this project.
About PCBWay:
With more than a decade in the field of PCB prototype and fabrication, They are committed to meeting the needs of their customers from different industries in terms of quality, delivery, cost-effectiveness, and any other demanding requests. As one of the most experienced PCB manufacturers in China, They pride themselves to be the best business partners as well as good friends in every aspect of our PCB needs.
They provide 2 layers of PCB just for $5, they also provide 4-6 layers of PCB manufacturing as well as SMT and STENCILS Services at very low cost and their other services are CNC and 3D Printing.
Make sure to visit their website PCBWay.com .
Raspberry Pi Pico and Motor Driver Wiring:
- Begin by establishing a connection between the Raspberry Pi Pico and the Motor Driver.
- Connect the following pins from the Motor Driver to the corresponding pins on the Raspberry Pi Pico:
- IN1 to GP3
- IN2 to GP4
- IN3 to GP5
- IN4 to GP6
- enA to GP2
- enB to GP7
These are all the connections required for the Motor Driver pins.
Bluetooth Module and Raspberry Pi Pico Wiring:
- Begin by establishing a connection between the Bluetooth Module and Raspberry Pi Pico.
- Connect the following pins from the Bluetooth Module to the corresponding pins on the Raspberry Pi Pico:
- Rx to Tx {GP0} (Raspberry Pi Pico)
- Tx to Rx {GP1} (Raspberry Pi Pico)
- GND to GND
- VCC to +5V {VBUS} (PIN 40)
After the connections have been established, you can proceed to upload the sketch. Before doing so, ensure that the Battery Holder is securely attached to the chassis using double-sided tape. Next, connect the GND wire of the Holder to the Motor driver’s Power GND Terminal and the +5V wire to the Vcc or +5V Terminal of the Motor driver.
Time to Upload the Sketch:
- Now connect the USB cable to the Raspberry Pi Pico.
Next, upload the following code:
# How to Make a Raspberry Pi Pico Bluetooth Control Car
# Please Subscribe and Support us - https://youtube.com/@roboatticLab
# Include the library files
from machine import UART,Pin, PWM
from time import sleep
# Set the relay pins as output pins
ENA = PWM(Pin(2))
IN1 = Pin(3,Pin.OUT)
IN2 = Pin(4,Pin.OUT)
IN3 = Pin(5,Pin.OUT)
IN4 = Pin(6,Pin.OUT)
ENB = PWM(Pin(7))
uart = UART(0, 9600)
# speed of this car
speed = 65025 # 0 - 65025
ENA.duty_u16(speed)
ENB.duty_u16(speed)
def forward():
IN1.on()
IN2.off()
IN3.on()
IN4.off()
def backward():
IN1.off()
IN2.on()
IN3.off()
IN4.on()
def left():
IN1.on()
IN2.off()
IN3.off()
IN4.on()
def right():
IN1.off()
IN2.on()
IN3.on()
IN4.off()
def stop():
IN1.off()
IN2.off()
IN3.off()
IN4.off()
while True:
if uart.any():
value = uart.readline()
print(value)
if value == b'U':
forward()
elif value == b'D':
backward()
elif value == b'L':
left()
elif value == b'R':
right()
elif value == b'S':
stop()
Working Video and Tutorial
Once the code has been uploaded, insert the battery into the Battery Holder to activate the project. A demonstration video of this project can be viewed here: Watch Now.
Thank you for your interest in this project. If you have any questions or suggestions for future projects, please leave a comment and I will do my best to assist you.
For business or promotional inquiries, please contact me via email at Email.
I will continue to update this instructable with new information. Don’t forget to follow me for updates on new projects and subscribe to my YouTube channel (YouTube: roboattic Lab) for more content. Thank you for your support.