PS2 handle remote control

This tutorial is a comprehensive experiment with multiple peripherals. You can learn about a single peripheral before doing the experiment.

1、software-hardware

2、Brief principle

2.1、Hardware schematic diagramimage-20231028102757858

2.2、Physical connection diagram

image-20231031094208747

Motor wiring:

image-20231031094208747

2.3、Principle of control

image-20231031094208747

modulefeature
PS2 handle receiverCommunication with the single chip microcomputer

image-20231031094208747

Key value rule:

Key nameKey value 
L111
L29
R112
R210
Arrow keys (up, down, left and right)5/7/8/6
Function key(X/A/Y/B)16/15/13/14
Select key1
Start key4

Note: The above key values are from the project code

PS2 handle is composed of a handle and a receiver. The handle is mainly responsible for sending key information. The receiver is connected to the microcontroller for receiving the information from the handle and passing it to the microcontroller. The microcontroller can also send commands to the handle through the receiver to configure the sending mode of the handle.

3、Main Function

function:PS2_ShortPoll

Function prototypesvoid PS2_ShortPoll(void)
Functional DescriptionHandle configuration initialization
Input parametersNone
Return valueNone

function:PS2_EnterConfing

Function prototypesvoid PS2_EnterConfing(void)
Functional DescriptionGo to Configuration
Input parametersNone
Return valueNone

function:PS2_SetInit

Function prototypesvoid PS2_SetInit(void)
Functional DescriptionHandle configuration initialization
Input parametersNone
Return valueNone

function:PS2_Cmd

Function prototypesvoid PS2_Cmd(uint8_t CMD)
Functional DescriptionHandle configuration initialization
Input parametersCMD instruction
Return valueNone

function:PS2_TurnOnAnalogMode

Function prototypesvoid PS2_TurnOnAnalogMode(void)
Functional DescriptionSending mode Settings
Input parametersNone
Return valueNone

function:PS2_ExitConfing

Function prototypesvoid PS2_ExitConfing(void)
Functional DescriptionFinish and save the configuration
Input parametersNone
Return valueNone

function:User_PS2_Control

Function prototypesvoid User_PS2_Control(void)
Functional Descriptionps2 controls the car
Input parametersNone
Return valueNone

4、Experimental phenomenon

After downloading the program successfully, connect the handle receiver to the expansion board.

Turn on the switch on the handle, and then we need to pair the handle receiver with the handle.

The pairing indicator is shown below: The handle receiver and the handle indicator are the traffic light is always on, if it is not, you can long press the "Mode" button on the handle to switch the handle mode to red and green mode.

image-20231031094208747

See the demo video for details: