Once the motors have been tested and everything has been properly assembled. We first need to install the IRremote.h library. This will allow us to directly interface with the IR remote and IR sensor, allowing us to read and interpret values from the IR remote. To install the library we need to navigate to
Sketch -> Include Library -> Manage Libraries
This should bring us to a searchable database of various libraries we can install. We can type in «IRremote» and install the correct one, it is important the library name matches exactly as various other libraries yet may have different syntax which may result in further errors.
Once installed, we can upload the ArduinoCar.ino file to the Arduino to let it operate remotely using a remote control. The code uses values that are common with most IR remotes. However, if the car does not behave as expected please modify the IR values within the code to reflect the values of your remote control.
The code provided improves upon the ARDUINO CAR TEST PROGRAM from the earlier steps and includes various IR functions to add the remote operation functionality. Once it detects a signal has been received from the IR remote, the value is stored and matched with pre-existing values to map to certain behaviors. Based on the mapped behavior, it will move the motors in the appropriate manner. If the value «16736925» is received, then it will search the pre-existing values and notice that «16736925» is mapped with moving the car forward, hence it will call upon the moveForward() function created in the ARDUINO CAR TEST PROGRAM. When testing, ensure to plug in the wires from the batteries into the breadboard to ensure the Arduino and motors are receiving power.
Once everything is functional and the buttons are mapped correctly, we can enjoy our Arduino Remote Control car.
If you would like to further improve your Arduino Remote Control Car, I would recommend, by having a dual battery system. A 9V for the motors, and 6V for the Arduino, this way, the motors have more juice and the car is able to have more operational time before the batteries need to switched. Additionally, more sensors can be added such as an ultrasonic to provide information such as distance from the closest object.