How to Make an IR-controlled car using a Raspberry Pi Pico board

Hello and welcome back. In this project, we will learn how to make an IR-controlled car using a Raspberry Pi Pico board. This is a very simple and attractive project that you can easily make at home. It is a 2WD car with front lights and a horn. We can control this car using any IR remote available in your house, such as a TV remote or DVD remote. Therefore, you do not need to buy a special remote for this project.
Also, we can program this car very easily using the Thonny IDE and MicroPython language. For the motor driving system, I have used a L293D motor driver module to control the DC motors. The Raspberry Pi Pico receives the IR signals from the remote and controls the car movements, such as forward, backward, left, right, and stop. Also, you can control the lights and the horn using the remote.
Especially, I have designed the chassis as a PCB using JLCPCB. Therefore, we do not need an additional chassis for this project. We can connect the components easily.
Ok, let’s do this project step by step. The required components are given below.
- Raspberry Pi Pico board x 1 — Our Store / Amazon
- IR Receiver x 1 — Our store / Amazon
- 5mm white LED x 2 — Our store / Amazon
- 180 ohm Resistor x 2 — Our store / Amazon
- L293D motor driver IC x 1 — Our store / Amazon
- IC base x 1 — Our store / Amazon
- 5V Active buzzer x 1 — Our store / Amazon
- Barrel jack socket x 1 — Our store / Amazon
- Two-pin terminal x 2 — Our store / Amazon
- Female header x 2 — Our store / Amazon
- Gear motor x 2 — Our store / Amazon
- 65mm Robot wheel x 2 — Our store / Amazon
- Cater wheel x 1 — Our store / Amazon
- Li-ion battery x 2 — Our store / Amazon
- Li-ion battery holder x 1 — Our store / Amazon
- LM7805 Voltage regulator x 1 — Our store / Amazon
- 100uf Capacitor x 2 — Our store / Amazon
- 1N4007 Diode x 1 — Our store / Amazon
- 100nf Capacitor x 1 — Our Store / Amazon
Disclosure: These Amazon links are Affiliate links. As an Amazon Associate, I earn from qualifying purchases.
Step 1
First, let’s identify these components.
















Step 2
Secondly, we will order the PCBs for this car.




- Click the “Instant Quote” button and upload the Gerber file, which you can download from the link below.
- Gerber file – Download
- For this project, I ordered five Yellow PCBs. Next, select the build time and shipping method. Finally, click “Save to Cart” and complete the payment.






Step 3
Thirdly, let’s unbox the package after receiving it.





Step 4
Afterward, solder the relevant components on the PCB.





Step 5
Next, connect the wheels to the motors and install them on the chassis. For that, I used double tape. After that, install the caster wheel on the rear side of the car. For that, I used copper columns and M3 bolts.






Step 6
Now, connect the motor wires to the motor terminals. After that, install the battery holder on the chassis and connect it to the power port.





Step 7
Afterward, connect the Raspberry Pi Pico board, the L293D motor driver, and the IR receiver to the PCB chassis. Then, connect the Raspberry Pi Pico board to the computer.




Step 8
Next, copy and paste the following program into the Thonny IDE.
#Include the library files
import time
from machine import Pin, freq, PWM
from ir_rx.print_error import print_error
from ir_rx.nec import NEC_8
#Define the IR receiver pin and motor pins
pin_ir = Pin(8, Pin.IN)
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))
#Lights
led1 = Pin(21,Pin.OUT)
led2 = Pin(20,Pin.OUT)
#Horn
buzzer = Pin(19,Pin.OUT)
# speed of this car
speed = 60000 # 0 - 65025
ENA.duty_u16(speed)
ENB.duty_u16(speed)
Up = 0
Down = 0
Left = 0
Right = 0
Stop = 0
lights_on = 0
lights_off = 0
horn_on = 0
horn_off = 0
def decodeKeyValue(data):
return data
# User callback
def callback(data, addr, ctrl):
if data < 0: # NEC protocol sends repeat codes.
pass
else:
print(data)
if data == Up:
forward()
elif data == Down:
backward()
elif data == Left:
left()
elif data == Right:
right()
elif data == Stop:
stop()
elif data == lights_on:
led1.on()
led2.on()
elif data == lights_off:
led1.off()
led2.off()
elif data == horn_on:
buzzer.on()
elif data == horn_off:
buzzer.off()
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()
ir = NEC_8(pin_ir, callback) # Instantiate receiver
ir.error_function(print_error) # Show debug information
try:
while True:
pass
except KeyboardInterrupt:
ir.close()
- Now, include the IR library file and click the Run button.





- Afterward, get the IR remote button values. For this, you can use any buttons you like. Then, copy and paste those values into the program.


- Next, save this code on the Raspberry Pi Pico as
main.py. Finally, click the Run button.




Step 9
Afterward, remove the USB cable and insert the batteries into the battery holder, then power on the car. Now you can control the car using your IR remote. Enjoy this project!
The full video guide is below. We hope to see you in the next project. Have a great day.



How to Make an IR-controlled car using a Raspberry Pi Pico board