yahboom
HomeTutorialsProduct
Solution
Blog
Online Store
About Us
EN/中文
Store
Pico Robot Car📖
0.Introduction
  • 0.1 Description of Pico Robot
  • 0.2 Interface Description
1.Assembly steps
  • Assembly video
2.Development environment construction
  • 2.1 Update firmware
  • 2.2 Build environment
  • 2.3 Download code Startup automatically
  • 2.4 Import library file
3.Basic course
  • 3.1 Control LED light
  • 3.2 Onboard temperature sensor
  • 3.3 Passive buzzer
  • 3.4 Breathing light
  • 3.5 Marquee light
  • 3.6 OLED display
  • 3.7 Battery power display
  • 3.8 Servo control
4.Advanced course
  • 4.1 Light sensor
  • 4.2 Sound sensor
  • 4.3 Tracking sensor
  • 4.4 Ultrasonic sensor
  • 4.5 IR control display
5.Robot course
  • 5.1 Car forward
  • 5.2 Car movement
  • 5.3 Singing dancing
  • 5.4 Car tracking
  • 5.5 Edge detection
  • 5.6 Ultrasonic avoiding
  • 5.7 Ultrasounic following
  • 5.8 Light follow
  • 5.9 Voice control car
  • 5.10 Infrared control
  • 5.11 Bluetooth control
6.Battery and charge
  • Battery and charge
Download
  • APP(iOS/Android)
  • Code
  • Instructions Manual
  • Appendix
Download ZIP

Welcome to Pico Robot Car repository

4.5 IR control display

4.5 Infrared remote control display

1. Learning objectives

  1. Learn the infrared reception and OLED combination of the Raspberry Pi Pico 2/Pico mainboard and the car expansion board.
  2. Understand the use of infrared reception.

2. Hardware usage

This course uses the infrared reception and OLED of the Pico 2/Pico mainboard and the car expansion board. In this example, we also need to use an infrared remote control to transmit infrared values ​​to the infrared receiver.

image-20220217112649860

image-20220321093338725

The spectrum of infrared light is outside the red light, and the wavelength is 0.76 to 1.5μm, which is longer than the wavelength of red light. Infrared remote control is a control method that uses infrared light to transmit information. Infrared remote control has the advantages of anti-interference, simple circuit, easy encoding and decoding, low power consumption and low cost. Infrared remote control is suitable for the control of almost all home appliances. The infrared receiving head has a built-in photoelectric element, which can receive infrared light of the corresponding wavelength and convert it into a digital signal. By reading the signal value, different remote control buttons can be judged.

 

3. About code

Code path: Code -> 2.Advanced course -> 5. IR control display.py

​x
import time
from machine import Pin, I2C
from pico_car import SSD1306_I2C, ir
#initialization ir
Ir = ir()
#initialization oled
i2c=I2C(1, scl=Pin(15),sda=Pin(14), freq=100000)
oled = SSD1306_I2C(128, 32, i2c)
​
while True:
    #get value
    value = Ir.Getir()
    time.sleep(0.01)
    if value != None:
        print(value)
        #display press
        if value == 0:
            while value == 0:
                value = Ir.Getir()
            oled.text('Press:Power', 0, 0)
            oled.show()
            oled.fill(0)
        elif value == 1:
            while value == 1:
                value = Ir.Getir()
            oled.text('Press:Up', 0, 0)
            oled.show()
            oled.fill(0)
        elif value == 2:
            while value == 2:
                value = Ir.Getir()
            oled.text('Press:Light', 0, 0)
            oled.show()
            oled.fill(0)
        elif value == 4:
            while value == 4:
                value = Ir.Getir()
            oled.text('Press:Left', 0, 0)
            oled.show()
            oled.fill(0)
        elif value == 5:
            while value == 5:
                value = Ir.Getir()
            oled.text('Press:Sound', 0, 0)
            oled.show()
            oled.fill(0)
        elif value == 6:
            while value == 6:
                value = Ir.Getir()
            oled.text('Press:Right', 0, 0)
            oled.show()
            oled.fill(0)
        elif value == 8:
            while value == 8:
                value = Ir.Getir()
            oled.text('Press:Turn Left', 0, 0)
            oled.show()
            oled.fill(0)
        elif value == 9:
            while value == 9:
                value = Ir.Getir()
            oled.text('Press:Down', 0, 0)
            oled.show()
            oled.fill(0)
        elif value == 10:
            while value == 10:
                value = Ir.Getir()
            oled.text('Press:Turn Right', 0, 0)
            oled.show()
            oled.fill(0)
        elif value == 12:
            while value == 12:
                value = Ir.Getir()
            oled.text('Press:+', 0, 0)
            oled.show()
            oled.fill(0)
        elif value == 13:
            while value == 13:
                value = Ir.Getir()
            oled.text('Press:0', 0, 0)
            oled.show()
            oled.fill(0)
        elif value == 14:
            while value == 14:
                value = Ir.Getir()
            oled.text('Press:-', 0, 0)
            oled.show()
            oled.fill(0)
        elif value == 16:
            while value == 16:
                value = Ir.Getir()
            oled.text('Press:1', 0, 0)
            oled.show()
            oled.fill(0)
        elif value == 17:
            while value == 17:
                value = Ir.Getir()
            oled.text('Press:2', 0, 0)
            oled.show()
            oled.fill(0)
        elif value == 18:
            while value == 18:
                value = Ir.Getir()
            oled.text('Press:3', 0, 0)
            oled.show()
            oled.fill(0)
        elif value == 20:
            while value == 20:
                value = Ir.Getir()
            oled.text('Press:4', 0, 0)
            oled.show()
            oled.fill(0)
        elif value == 21:
            while value == 21:
                value = Ir.Getir()
            oled.text('Press:5', 0, 0)
            oled.show()
            oled.fill(0)
        elif value == 22:
            while value == 22:
                value = Ir.Getir()
            oled.text('Press:6', 0, 0)
            oled.show()
            oled.fill(0)
        elif value == 24:
            while value == 24:
                value = Ir.Getir()
            oled.text('Press:7', 0, 0)
            oled.show()
            oled.fill(0)
        elif value == 25:
            while value == 25:
                value = Ir.Getir()
            oled.text('Press:8', 0, 0)
            oled.show()
            oled.fill(0)
        elif value == 26:
            while value == 26:
                value = Ir.Getir()
            oled.text('Press:9', 0, 0)
            oled.show()
            oled.fill(0)
        value = None

We use while value == key value: to achieve the effect of pressing and releasing the remote control and then executing.

from pico_car import SSD1306_I2C, ir

Use SSD1306_I2C and ir from pico_car, which is our packaged OLED and IR receiver library.

import time

The "time" library. This library handles everything time related, from measuring it to inserting delays into programs. The unit is seconds.

from machine import Pin, I2C

The machine library contains all the instructions that MicroPython needs to communicate with Pico and other MicroPython-compatible devices, extending the language of physical computing, using the Pin and I2C libraries here.

i2c=I2C(1, scl=Pin(15),sda=Pin(14), freq=100000)

Set the IIC 1 pin to SCL 15, SDA 14, and the frequency to 100000.

oled = SSD1306_I2C (128, 32, i2c)

Initialize the size of the OLED to 128*32, and pass in the IIC parameters set earlier.

Ir = ir ()

Initialize the infrared remote control.

value = Ir.Getir ()

Read the infrared remote control value and assign it to the variable value.

oled.show ()

Display the set OLED content.

oled.fill (0)

Clear the settings and prepare for the next display.

oled.text ('Press: Power', 0, 0)

isplay the corresponding key on the OLED, for example, press the power key to display 'Press: Power'.

 

4. Experimental Phenomenon

After the code is downloaded, when we press the button on IR controller, the corresponding button name will be displayed on the OLED.

At the same time, the print shell will also print corresponding button value.

image-20220302143907708

As shown below.

KeysShell prints key valuesOLED display
Power0Press:Power
Up1Press:Up
Light2Press:Light
Left4Press:Left
Sound5Press:Sound
Right6Press:Right
Turn Left8Press:Turn Left
Down9Press:Down
Turn Right10Press:Turn Right
+12Press:+
013Press:0
-14Press:-
116Press:1
217Press:2
318Press:3
420Press:4
521Press:5
622Press:6
724Press:7
825Press:8
926Press:9
Ultrasonic sensor
Car forward

COMPANY

  • About us
  • Team Style
  • Blog

LEARNING & EXPLORATION

  • Tutorials
  • Edge AI hardware
  • Educational robots
  • Embedded intelligent hardware

WHERE TO BUY

  • Yahboom Online Store
  • Amazon
  • Alibaba
  • AliExpress
  • Mercado

TECHNOLOGY SUPPORT

  • Email: support@yahboom.com

BE A DISTRIBUTOR

  • Email: sales@yahboom.com
QR Code

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文