yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
Roboduino V2📖
0.Instruction manual
  • Instruction manual
1.Get started quickly
  • 01.Assembly of the Car
  • 02.Remote Control Car
  • 03.Common Problem Analysis
  • 04. Lithium Battery Pack and Charger Usage Guidelines
  • 05. Important Notes (Read Before Starting)
2.Environment Construction
  • 01.Serial port driver installation
  • 02.Arduino IDE Installation
  • 03.Arduino IDE usage
  • 04.Using third-party libraries
  • 05.Program compilation and upload
3.Basic car course
  • 01.RGB Control
  • 02.Serial Print
  • 03.KEY Read
  • 04.Buzzer control
  • 05.Logo Breath
  • 06.Servos Control
  • 07.Motor Control
  • 08.Ultrasonic Ranging
  • 09.Track Print
  • 10.Infrared Remote Print
  • 11.WIFI Camera
4.Advanced car course
  • 01.RGB Breath
  • 02.Play Music
  • 03.KEY Control RGB
  • 04.KEY Control Buzzer
  • 05.Serial Parse Data
  • 06.Parse Data Control Motor
  • 07.Parse Data Control RGB
  • 08.Parse Data Control Buzzer
  • 09.Parse Data Control Servo
5.Car motion control
  • 00.Mecanum wheel motion principle
  • 01.Car Vertical Movement
  • 02.Car Diagonal Movement
  • 03.Car Sideways Movement
  • 04.Car Rotational Movement
  • 05.Car Patrol
6.Comprehensive gameplay of car
  • 01.Car tracking
  • 02.Car Obstacle Avoid
  • 03.Car Follow Hand
  • 04.Car tracking Avoid
  • 05.Car Infrared Remote
  • 06.WiFi Control Car
  • 07.IR WiFi Control Car
7.AI vision course
  • 1. Cat(dog) detection
  • 2. Color recognition
  • 3. QR code instructions
  • 4. Person Recognition
  • 5. Face Detection
  • 6. Color Follows
  • 7. Face following
8.Expand peripherals
  • 01.Digital Tube Display
  • 02.Color Recognition
Download
  • Code
  • Library
  • Hardware manual
  • Software
  • 3D Model
  • Instruction Manual
Download ZIP

Welcome to Roboduino V2 repository

05.Car Infrared Remote

Car Infrared Remote

Car Infrared Remote

Car Infrared RemoteDevice connectionHardware connectionSoftware connectionImplementation ideasCode AnalysisExperimental resultsNotes

Control RGB, buzzer and car motion status through infrared remote control.

xxxxxxxxxx
Since the previous tutorial has explained the basic knowledge of all car modules, the car control tutorial will not repeat it, and mainly explain the ideas for implementing car functions!

Device connection

Hardware connection

Use Type-B data cable to connect Arduino Uno and computer.

Software connection

Open the "Arduino IDE" software and select the model and serial port number corresponding to the development board.

Implementation ideas

Use the infrared remote control with the infrared receiver to parse the data, and then control the corresponding peripheral status of the car according to the data.

IR remote controlParsed dataFunction
Power0x00Stop all peripheral functions
RGB0x40Switch RGB colors
Buzzer0xA0Control buzzer sound
Car Forward0x80Car forward
Car Backward0x90Car backward
Car Left0x20Car moves to the left
Car Right0x60Car moves to the right
Car Left Spin0x10Car rotates to the left
Car Right Spin0x50Car rotates to the right
Add0x30Increase speed
Sub0x70Decrease speed
Number 00xB0None
Number 10x08None
Number 20x88None
Number 30x48None
Number 40x28None
Number 50xA8None
Number 60x68None
Number 70x18None
Number 80x98None
Number 90x58None

Code Analysis

Here is only a brief introduction to the code content. For detailed code, please refer to the corresponding code file, which is provided in the download area!

  • Include Wire、IRremote、Adafruit_NeoPixel、Adafruit_PWMServoDriver library

xxxxxxxxxx
#include <Wire.h>                     // 包含Wire(I2C)通讯库 Include Wire library
#include <IRremote.hpp>               // 包含IRremote库 Include IRremote library
#include <Adafruit_NeoPixel.h>        // 包含Adafruit NeoPixel库 Include Adafruit NeoPixel library
#include <Adafruit_PWMServoDriver.h>  // 包含Adafruit PWMServoDriver库 Include Adafruit PWMServoDriver library
  • Define motor, infrared, RGB, buzzer control pins, I2C address, motor frequency and initial speed, etc.

​x
// 定义红外接收引脚 Define IR receiver pins
#define IR_RECEIVE_PIN A3

// 定义电机控制引脚 Define motor control pins
#define Motor_L1_F_PIN 11  // 控制小车左前方电机前进 Control the motor on the left front of the car
#define Motor_L1_B_PIN 10  // 控制小车左前方电机后退 Control the motor back on the left front of the car
#define Motor_L2_F_PIN 8   // 控制小车左后方电机前进 Control car left rear motor forward
#define Motor_L2_B_PIN 9   // 控制小车左后方电机后退 Control the car left rear motor back
#define Motor_R1_F_PIN 13  // 控制小车右前方电机前进 Control the right front motor of the car to move forward
#define Motor_R1_B_PIN 12  // 控制小车右前方电机后退 Control the motor back on the right front of the car
#define Motor_R2_F_PIN 14  // 控制小车右后方电机前进 Control car right rear motor forward
#define Motor_R2_B_PIN 15  // 控制小车右后方电机后退 Control car right rear motor back

// 控制LOGO对应的LED引脚 Control LED pins
#define LED_PIN 7

// 定义底层驱动芯片参数 Bottom-layer driver chip related parameters
#define Bottom_Layer_Driver_ADDR 0x40

// 定义PWM频率 Define PWM frequency
#define PWM_FREQUENCY 50

// 定义RGB控制引脚和数量 Define RGB control pins and quantity
#define RGB_PIN 6
#define RGB_NUM 1

// 定义蜂鸣器控制引脚 Define BUZZER control pins
#define BUZZER_PIN 10

// 定义红外键值对应的红外数据 Define the value corresponding to the infrared remote control key
const uint8_t Power = 0x00;
const uint8_t RGB_Light = 0x40;
const uint8_t Buzzer = 0xA0;
const uint8_t CarForward = 0x80;
const uint8_t CarBackward = 0x90;
const uint8_t CarLeft = 0x20;
const uint8_t CarRight = 0x60;
const uint8_t CarLeftSpin = 0x10;
const uint8_t CarRightSpin = 0x50;
const uint8_t Add = 0x30;
const uint8_t Sub = 0x70;
const uint8_t Number_0 = 0xB0;
const uint8_t Number_1 = 0x08;
const uint8_t Number_2 = 0x88;
const uint8_t Number_3 = 0x48;
const uint8_t Number_4 = 0x28;
const uint8_t Number_5 = 0xA8;
const uint8_t Number_6 = 0x68;
const uint8_t Number_7 = 0x18;
const uint8_t Number_8 = 0x98;
const uint8_t Number_9 = 0x58;

int iCarSpeed = 75;
unsigned int uRgbState = 0;
  • Enumerate common colors

xxxxxxxxxx
// 枚举常见颜色 Enumerate common colors
enum ColorType {
  BLACK,
  RED,
  GREEN,
  BLUE,
  YELLOW,
  MAGENTA,
  CYAN,
  WHITE,
};
  • Enumerate the common movement modes of omnidirectional cars

xxxxxxxxxx
// 枚举全向小车的常见运动方式 Enumerate the common movement modes of omnidirectional cars
enum OmniDirectionalCar {
  STOP,
  FORWARD,
  BACKWARD,
  LEFT,
  RIGHT,
  LEFT_ROTATE,
  RIGHT_ROTATE,
  LEFT_FORWARD,
  RIGHT_BACKWARD,
  RIGHT_FORWARD,
  LEFT_BACKWARD,
};
  • Create an instance of the Adafruit_PWMServoDriver class

xxxxxxxxxx
// 创建Adafruit_PWMServoDriver类的实例 Create an instance of the Adafruit_PWMServoDriver class
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(Bottom_Layer_Driver_ADDR);
// 创建Adafruit_NeoPixel类的实例 Create an instance of the Adafruit_NeoPixel class
Adafruit_NeoPixel RGB = Adafruit_NeoPixel(RGB_NUM, RGB_PIN, NEO_GRB + NEO_KHZ800);
  • Setting the Motor Speed

xxxxxxxxxx
/**
 * @brief 设置单个电机速度 Setting the Motor Speed
 * @param motor_forward_pin: 控制电机前进引脚 Control the motor forward pin
 * @param motor_backward_pin: 控制电机后退引脚 Control the motor backward pin
 * @param motor_speed: 设置电机速度 Setting the Motor Speed
 * @retval 无 None
 */
void setMotorSpeed(uint16_t motor_forward_pin, uint16_t motor_backward_pin, int motor_speed) {
  motor_speed = map(motor_speed, -255, 255, -4095, 4095);
  if (motor_speed >= 0) {
    pwm.setPWM(motor_forward_pin, 0, motor_speed);
    pwm.setPWM(motor_backward_pin, 0, 0);
  } else if (motor_speed < 0) {
    pwm.setPWM(motor_forward_pin, 0, 0);
    pwm.setPWM(motor_backward_pin, 0, -(motor_speed));
  }
}
  • Set the car movement mode and speed

xxxxxxxxxx
/**
 * @brief 设置小车运动方式和速度 Set the car movement mode and speed
 * @param Movement: 小车运动方式 Car movement
 * @param Speed: 小车运动速度 Car speed
 * @retval 无 None
 */
void setCarMove(uint8_t Movement, int Speed) {
Car tracking Avoid
WiFi Control Car

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/中文