roboattic Lab
Published © CC BY-NC-SA

How to Make a Raspberry Pi Pico Bluetooth Control Car

A Raspberry Pi Pico Project.

IntermediateFull instructions provided3 hours577
How to Make a Raspberry Pi Pico Bluetooth Control Car

Things used in this project

Hardware components

Raspberry Pi Pico
Raspberry Pi Pico
×1

Software apps and online services

Thonny IDE

Story

Read more

Code

How to Make a Raspberry Pi Pico Bluetooth Control Car Code

MicroPython
# 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()       

Credits

roboattic Lab

roboattic Lab

10 projects • 9 followers
YouTube Content Creator Robotics Enthusiast

Comments