MakeCode JoyCar Remote Control
Here you can find complete demo programs, for starting your Joy-Car.
With these two example programs you can remote control your JoyCar with the help of a second micro:bit. For this purpose the accelerometer and the BT radio connection is used.
The program RC-JoyCar has to be uploaded to the micro:bit inside the JoyCar, the program RC-Remote to the micro:bit you want to use as remote control.
The RC-Remote program uses the accelerometer to detect how the micro:bit is held. If the remote control is tilted to one side, the JoyCar should move in the corresponding direction. The X- and Y-axis values of the accelerometer range from -1000 to +1000, where 0 is the center point when the micro:bit is held straight. To prevent the JoyCar from starting at the slightest movement of the remote control, we have added the threshold value of -300 and +300 respectively. This value must be reached when tilting the remote control for the JoyCar to start moving. Also you can activate the horn with button A and the headlights with button B. The data is passed in the form of a string with two characters. The first character indicates the driving direction and the second character indicates the status of the buttons.
The RC-JoyCar program receives the transmitted data of the remote control via the BT radio link and evaluates them. The received string is split into the two contained characters and evaluated.
The first character in the string indicates the driving direction, the motors of the JoyCar are controlled by this data.
The second character indicates the status of the buttons, with this data the horn and the headlights are controlled.