KevsRobots Learning Platform
64% Percent Complete
By Kevin McAleer, 3 Minutes
Page last updated May 10, 2025
With Bluetooth, you can control your robot wirelessly from a phone, tablet, or PC — no need to tether it with a USB cable. In this lesson, we’ll connect an HC-05 module to the Raspberry Pi Pico and send simple commands to drive the robot.
HC-05 Pin | Connect to |
---|---|
VCC | 3.3V or 5V (check module label) |
GND | GND |
TXD | GP1 (Pico RX) via voltage divider (1kΩ + 2kΩ) |
RXD | GP0 (Pico TX) – use voltage divider to step down 3.3V if HC-05 is 3.3V tolerant |
💡 The HC-05 RX pin must not receive 3.3V directly from Pico TX. Use a voltage divider (e.g., 1kΩ + 2kΩ).
from machine import UART, Pin, PWM
from time import sleep
# Set up Bluetooth UART
uart = UART(0, baudrate=9600, tx=Pin(0), rx=Pin(1))
# Motor pins (update to match your setup)
# ...
def forward():
print("Forward")
# motor code here
def backward():
print("Backward")
# motor code here
def left():
print("Left")
# motor code here
def right():
print("Right")
# motor code here
def stop():
print("Stop")
# motor stop code here
# Main loop
while True:
if uart.any():
cmd = uart.read(1)
if cmd == b'f':
forward()
elif cmd == b'b':
backward()
elif cmd == b'l':
left()
elif cmd == b'r':
right()
elif cmd == b's':
stop()
Use a Bluetooth terminal app and pair it with the HC-05 (usually pin 1234 or 0000). Then send single-character commands:
Now you can drive your robot like an RC car — all with MicroPython!
Next up: Wi-Fi Control with the Raspberry Pi Pico W
You can use the arrows ← →
on your keyboard to navigate between lessons.