This is the second of three articles and videos on construction and using the Elegoo Smart Robot Car V3 kit. If you missed the first installment you can check it out here.


The Elegoo Smart Robot Car Kit is an attractively priced Arduino-based robot car with features like Bluetooth and Infrared Remote control, Line Following and Collision Avoidance. In the first article and video, I put the car together and used a sketch to test out the motors. Today we will look at the Bluetooth and Infrared remote control functions.

Keep in mind that what is shown here applies to other Arduino-based robot car designs, you can use the sketches and app described in this article even if you don’t own the Elegoo car.

The kit comes packaged with an Infrared remote control, this is a pretty standard device and is similar to the one I used in my article about using IR remote controls. For Bluetooth, Elegoo has made available an app for both Android and IOS devices that you can use as a remote control.

Elegoo Smart Robot Car Part 2

On the Arduino side, Elegoo has provided a few sample sketches to get you started with both remote modes.  You can customize them to your liking or use them “as-is”.

So let’s get started with the Bluetooth remote control.

Bluetooth Remote Control

Bluetooth devices are everywhere, from keyboards to headphones they make it possible to connect external peripherals to our computers, tablets, and phones with very little effort.

In the Elegoo Smart Robot Car Bluetooth can be used as a remote control, in conjunction with a custom app that you can run on your phone or tablet.


Bluetooth Module on Robot Car

Like all of the car features, this is highly programmable, allowing you to customize the remote any way you like. So if you ad some external peripherals like headlights or a horn to your car you can use the Bluetooth app to control it.

How Bluetooth Works

Bluetooth is a short-range wireless technology for transmitting and receiving data. It operates in the ISM (Industry, Scientific, and Medical) band from 2.400 to 2.485 GHz.

Bluetooth is intended to be used in PAN or Personal Area Networks and is typically limited to a maximum range of 100 meters (about 330 feet). Not all Bluetooth devices can achieve this range, some can only operate to a maximum of 10 meters. As with all radio communications the range can be affected by the environment it is used in.

Bluetooth was originally developed by engineers at Ericsson Mobile in Sweden in 1989. Nils Rydbeck, the Chief Technology Officer at Ericsson, named the standard Bluetooth after the tenth-century king Harald Bluetooth.  The king had united a number of Danish tribes, just like modern devices from different manufacturers are united using Bluetooth.

Bluetooth Module

The Elegoo Smart Robot Car has a Bluetooth Module mounted on the Arduino shield. The module is a generic version of the popular HC-05 or HC-08 modules.

Bluetooth Module Connections

These modules have a working voltage of 3.3 volts but are 5-volt logic tolerant. They can operate at speeds of up to 115,200 baud. In the sketches we will look at the modules are used at 9600 baud.

The modules also support the AT Command Set, a standard set of commands that begin with the text string “AT”. This command set has been around for decades and was first used on computer modems in the 1980s.

In the Elegoo Smart Robot Car the Bluetooth module is connected to the RX (receive) and TX (transmit) pins on the Arduino, which are also digital I/O pins 0 and 1.  These are the same connections used by the USB port on the Arduino.

Bluetooth Arduino Hookup

The result is that you cannot use both the Bluetooth module and the USB port simultaneously. This presents a bit of a problem when you want to upload sketches to the car.

The solution is to simply remove the module from the car before you upload sketches. This is quite easy to do as the module just plugs into the Arduino shield. I would suggest that you turn off all of the power (including power from the USB connector itself) before removing or inserting the module.

Elegoo Bluetooth App

In order to use the Bluetooth module on the Elegoo Smart Robot Car, you will need a Bluetooth app to control it.  There are a number of Bluetooth apps made for controlling modules like the HC08. If you wish you can use any one of these to control the car.

Elegoo has provided their own app which you can install on your phone or tablet. It is available for both Android and Apple IOS platforms.

A copy of the Android app is provided as an APK file on the CD that is included with the car, it also is in the download from the Elegoo site. You may also get the app on the Google Play Store, for most people this is an easier method of installing it.

If you have an Apple device you can get the app by searching the App Store for “ELEGOO BLE Tool” on your iPhone or iPad.

Connecting the app and the car

After you install the app and enable Bluetooth you will need to set it up to be used with your robot car.  I’ll describe how I set it up on an Android tablet but I’m sure that the procedure is nearly identical on an IOS device (I don’t own an iPhone or iPad so I couldn’t test it).

The first thing to do is to start the app. If your devices Bluetooth is not turned on you’ll be prompted to do that.  Make sure that you have powered up the Smart Robot Car as well.

When the app has started you will see a link that says Connection. Touch it and you should get a list of the Bluetooth devices that you are paired with, as well as other devices within range of your tablet or phone.

Look for the device named HC-08. Select it and it should move to the top of the screen. Now exit the connection screen.

Elegoo Bluetooth App Connection Screen

If all is working properly you should see HC-08 at the top of the screen.

The app has three modes – Terminal, Chat, and Keyboard. We will be using it in Keyboard mode.

Defining Keys

The Keyboard mode of the app has 12 square “blocks” on the screen, these “blocks” are what you will actually define as keys for your remote control.  You can define what character or characters are sent when you press the key. Then on the receiving side (on the robot car) you’ll write a sketch to interpret these characters and act accordingly.

You set up the keys by holding down the key you wish to define. A button editor box will pop up.

Elegoo Bluetooth App Button Editor

You need to type in the name that you want to be printed on the button, followed by the character that you will be sending to the robots Bluetooth adapter.  You can also set the background color of the button to something unique to distinguish it.

You actually need to do it twice on each editor screen. I’m really not sure why!

Here are the buttons you will need to define, along with their characters:

  • Light – a
  • Forward – f
  • Left – l (that’s a lowercase “L”)
  • Stop – s
  • Right – r
  • Back – b

Once you have the keys defined you are ready to begin controlling your robot car using Bluetooth.

Bluetooth Blink Sketch

Before we start driving around the room under Bluetooth control it’s a good idea to test everything out to be sure it is all working.  

Elegoo has provided a sketch for you to use for that purpose.  It is called the “Bluetooth Blink” sketch, as with the original Arduino “Blink” sketch it controls an LED attached to pin 13 on the Arduino Uno.

The shield on the Elegoo Smart Robot Car also has an LED attached to pin 13, a lot easier to see as the one on the Uno is hidden by the shield.

The sketch uses the button you defined as “Lamp”, which has been set to transmit the letter “a” when it is pressed. Pressing the button will toggle the LED on pin 13 on and off.

Here is the Bluetooth Blink sketch


The sketch is actually pretty simple but it illustrates the operation of the Bluetooth module quite nicely.

We start by defining a constant called LED and assigning it a value of 13, this represents the LED attached to digital I/O pin 13.

Next, a boolean named state is defined and assigned a value of LOW. This boolean is used to represent the state of the LED with LOW indicating it is off and HIGH indicating that it is on.

Finally, a character variable called getstr is defined, this will hold the character that we receive from the Bluetooth remote control app.  This corresponds to the “Light” key that we defined earlier in the Bluetooth app.

In the Setup function, we set the baud rate of the serial port at 9600 baud. Remember, the Bluetooth module is wired to the serial port so this line sets its speed.  We also set the LED pin as an output.

Next, a function called stateChange is defined. This function reads the current value of the state variable, inverts it and then controls the LED with it. This serves to toggle the LED on and off each time it is called.

Finally, in the Loop, we read the value of the data from the serial port and assign it to the getstr variable. If the value is “a” then we call the stateChange function to toggle the LED.

Rember, you’ll need to remove the Bluetooth module before you upload the sketch. And of course, you need to replace the module to run the sketch.

Once you have the sketch loaded insert the Bluetooth module and power up the robot car. Then connect the Elegoo BLE Bluetooth app to the HC-08 on the robot car. Now press the “Light” button and observe the LED.

Pin 13 LED on Arduino Shield

To make things easier there is an LED on the Arduino shield that is also connected to pin 13, you can see it in the image above.

Once you’ve established that your Bluetooth module and remote control are working it’s time to control the robot car. We will need another sketch to do that.

Bluetooth Car Control

Controlling the car using Bluetooth is a simple matter of loading a different sketch, one that can interpret all of the characters sent from the remote control app and drive the car accordingly.

In part one of this series, we used a sketch called AUTO_GO to test the operation of the motors and the H-Bridge controller.  Our Bluetooth car control sketch uses some of the same functions, it’s essentially an amalgamation of the AUTO_GO sketch with the Bluetooth Blink sketch.

Defining Control Keys

You have already defined the keys on the app that controls the car so you should be good to go.

Bluetooth Remote Control on Android

Here is what my Android tablet looked like after I finished defining all of the keys. You can experiment with different button colors and positions if you like.  You could also use different characters if you really wanted to, however, if you do you will need to adjust the sketch to match them.

Bluetooth Car Sketch

Here is the Bluetooth Car sketch.


We start by defining all of the connections to the L298N H-Bridge controller.

Next, we define a character variable called carSpeed. In this sketch we drive the car at full speed when going forward or backward but when we turn left or right we slow it down.  We do this by toggling the Enable lines on the L298N using PWM (Pulse Width Modulation). If you are unsure about how this works I have an article about using the L298N H-Bridge to control DC motors, you might want to check it out.

Now you might need to experiment with the value for carSpeed. I found that the value of 150 that Elegoo provided was not high enough to effectively turn my robot car, I changed the value to 220 for my car and it worked just fine.

The functions forward, back, left, right and stop are virtually the same as they were in the AUTO_GO sketch, they just spin the motors in the proper directions to move the car. Note that the left and right functions have been modified to control the motor speed using the carSpeed variable and the Arduino analogWrite function.

The stateChange function is identical to the one used in the Bluetooth Blink sketch we just looked at.

In the Setup we set the baud rate of the serial port to 9600, again this port is used for the Bluetooth module. The LED and all the connections to the L298N H-Bridge motor controller are set as outputs.

Before we exit the Setup function we call the stop function to ensure that when the car is powered up the motors are stopped.

And then the loop. It’s actually pretty simple, we read the incoming character and look for cases that correspond to a car control function and then call that function. So, for example, if we receive an “f” we call the forward function to move the car forward.

Load the sketch, replace the Bluetooth module and give it a test. You should be able to control your car using the app.

One thing to note is that once you give the car a command it will keep executing it until you press Stop or give it another command.

Infrared Remote Control

Now that we have mastered controlling your robot car with Bluetooth it’s time to move on to using the Infrared remote control.

Infrared Remote Basics

I have covered Infrared remote controls in great detail in another article so I won’t go too far in depth about them here. But for those of you who need a refresher course here are the basics.

Infrared, or IR, remote controls operate using (what else?) infrared light, which is light just below the red end of the visible spectrum. You likely have several of them in your home as they are used for televisions, sound systems and all sorts of appliances.

Infrared remotes are very inexpensive to manufacture as the IR LED’s and receivers that they use are very common low-cost devices. They work on a “line of sight” principle, you need to be able to “see” the receiver with the remote control in order for it to function correctly.  In some cases the signal will bounce off of walls and other reflective surfaces, extending the range of the IR remote control.

Aside from the problem that arises when an object obstructs the infrared beam IR remotes can also suffer from interference from other infrared sources. Common sources of infrared light are sunshine and old-fashion incandescent light bulbs.

IR Remote Function

IR remote controls use pulses of encoded infrared light to send data to the receiver. The pulses are modulated, usually at 38 KHz, in order to reduce the effect of outside interference.

On the receiving end, an IR sensor picks up the pulses and decodes them. The data is extracted from the signal and used to control the device.

Infrared  Remote Control & Receiver

The Elegoo Smart Robot Car comes with an IR remote control. It’s a pretty standard generic remote control, in my video about IR remotes I used one very similar to it.

IR Remote Control for Robot Car

Like all IR remotes, the device emits a unique code corresponding to the key that is pressed. It actually has two codes for each key, one for a brief keypress and another that is generated when you hold the button down for more than a second – this is the ”repeat” function.

The receiver for the IR signal is mounted on the Arduino shield included with the car.  You need to make note of its location if you are planning to add more equipment to your car, you don’t want to obstruct the light beam from hitting the sensor.

IR Module on Arduino Shield

I found that the sensor is also pretty sensitive to infrared light coming from above and was able to control my robot car while standing over it.

Infrared  Arduino Connection

The IR sensor is a very simple device, it only has three leads.

IR Sensor Pinout

  • Output – The data extracted from the modulated infrared beam.
  • Ground – The ground connection.
  • VCC – The positive voltage used to operate the sensor.

The connection of the IR sensor to the Arduino is equally simple. The Output of the sensor is connected to digital I/O pin 12 on the Arduino.  The only other connections are power and ground.

IR Sensor Arduino Hookup

Of course on the Elegoo Smart Robot Car, the connection to the sensor is already made using the custom shield.

IR Arduino Library

In order to facilitate using the IR remote control you will need to install a library into your Arduino IDE.

The IRremote library is provided by Elegoo on the CD ROM included with the robot car or in the download from the Elegoo site.  It is packaged in a ZIP file for easy installation.

In the IDE click on the Sketch menu in the top menu bar. Move down to Include Library and a sub-menu will open.

From this sub-menu choose Add ZIP Library. A file selection dialog box will be displayed, use it to navigate to the location you stored your ZIP file (or to the location on the CD ROM if you are using that).

Select the file. The library will be extracted and installed in your Arduino IDE.

Once you have the library installed you are ready to run the sketches to use the infrared remote control with your Elegoo Smart Robot Car.

Infrared  Blink Sketch

As with the Bluetooth remote control, we will begin with a simple sketch to test out the operation of the IR Remote.

The Infrared Blink sketch is similar to the Bluetooth Blink sketch we ran earlier, and you’ll likely notice that some of the code is repeated.


The sketch starts by including the IRremote library you just installed.

We then define a constant RECV_PIN as 12 to correspond with the pin that the IR sensor is connected to.  We also define an LED constant to represent the LED on pin 13.

The next two definitions, L and UNKNOWN_L, represent the code from the remote control. The second one is the repeat sequence. Note that Elego has chosen to use decimal values for these code inst=ead of the more commonly used hexadecimal values.

The state and val variables are used as they were in the sketches we have already looked at.

Next, we initialize the IR receiver and define a variable to hold the results it receives.

The stateChange function is identical to the one we saw earlier, it toggled the LED on and off.

In the Setup function we set the LED pin to be an output and the serial line (for debugging if we need it) to 9600 baud. We also enable the IR receiver.

In the Loop, we check to see if the IR receiver has decoded data. If it has then we assign the value of that data to the val variable and print it to the serial port to be used with the serial monitor. This makes it easy to decode all of the keys on our remote, useful when you want to customize it.

We then resume listening with the IR receiver and add a short 150 ms time delay to prevent double-triggering.

Finally, we check the value of the data we received from the remote control. If it is L or UNKNOWN_L then we call the stateChange function to toggle the LED.

Load up the code and try it out. The LED should be toggled using the Left arrow on the remote control.

Infrared Remote Car Control

Now that we have verified that our remote control and receiver are working it’s time to load some code to drive the car.

The code we will be using makes use of the four arrow keys plus the “OK” key, all of the other keys on the remote control are ignored. Of course, you could repurpose the code to use the additional buttons for whatever your heart desires.

IR Remote Sketch

The IR Remote sketch is shown below.


After seeing the sketch to control the car using the Bluetooth remote and the IR Blink sketch I think you’ll have no problem understanding the Infrared Remote Control Car sketch.  All of the functions have been taken from those two sketches.

At the beginning of the sketch we define the codes for all of the buttons we are using on the remote control, again there are two values to accommodate the repeat function.

Note that in the Setup function we again call the stop function, to ensure that the car is not moving when it is first powered up.

In the Loop we use a switch function to evaluate the incoming data. If it matched one of our defined patterns then we call the appropriate function.

The one function you may not be familiar with is the Arduino millis function. This function returns the number of milliseconds that have elapsed since the Arduino was powered up or rebooted. It is being used as a timer here instead of the delay function, which is a good practice as the delay function prevents the Arduino from doing anything else while it is running.  We use it here to delay for half a second between reading the IR signals, to prevent false triggers.

Load up the sketch, put your car on the floor and turn it on. Point the remote control at it and take it for a test drive.

Note that unlike with the Bluetooth remote sketch the car only moves as long as you hold down the button. In fact, I’m not sure why we bothered to encode the Stop (OK) button as it is never really used!

Comparison of both remote control methods

There are advantages and disadvantages to both types of remote controls.

Bluetooth has an advantage in that it is not “line of sight” as long as your car remains within the range of your phone or tablet you can control it. You also don’t need to “aim” the remote control at the car. As long as the radio signal can make its way to the car you can use your remote control to drive it.

A disadvantage of Bluetooth is that you need a phone or a tablet, which are a lot more expensive than an IR remote control. But it is likely that you already have one anyway.

The IR remote has an advantage over Bluetooth if you need to do some troubleshooting with the Arduino Serial Monitor. This is very handy if you are developing uses for the unused buttons on the remote control, or if your sketch isn’t working the way you wanted it to.  Since the designers at Elegoo used the Arduino serial lines for the Bluetooth module it prevents you from using the serial monitor and Bluetooth module at the same time.

Both remote controls work well with the robot car. And if you’re adventurous you could even write your own sketch to use both of them.

What’s Next?

This was the second article and video I’m doing about the Elegoo Smart Robot Car.  The third and final ones will be out very soon and I’ll cover the Collision Avoidance and Line Following capabilities of the robot car.

Until then have fun controlling your car with both Bluetooth and infrared light. Drive safely!



Elegoo Smart Robot Car – The sales page for the Elegoo Smart Robot Car

Elegoo Robot Car Software – The latest version of the instruction manual and the software for using the robot car.



Elegoo Smart Robot Car Part 2 – Bluetooth and IR Remote Control
Elegoo Smart Robot Car Part 2 - Bluetooth and IR Remote Control
Article Name
Elegoo Smart Robot Car Part 2 - Bluetooth and IR Remote Control
In part two of the series on building the Elegoo Smart Robot Car, I will show you how to use both the Infrared and Bluetooth remote controls.
Publisher Name
DroneBot Workshop
Publisher Logo

Leave a Reply

newest oldest most voted

nice tutorial!


Excellent tutorials. At 75 was having trouble getting started. Now much improved but having trouble integrating different actions. My car motors are roughly the same as your sketch but when I add a sketch for two servos only one motor works with the two servos. The second motor is stopped totally. Also am trying to change the speed of the motors for different actions. For example enA and enB set at 200 but want to reverse slowly so with void Reverse() set enA and enB to 100 but there is no change in speed. I guess I have missed something… Read more »