Introduction: Arduino Uno and Visuino: Control Smart Car Robot With Joystick and L298N Motor Driver
Smart Car sets when combined with L298N Motor Driver Modules, offer one of the easiest ways to make robot cars. The L298N Motor Driver Module is easy to control with Arduino, and with the help of Visuino you can program your car in seconds.
In this Instructable I will show you how easy it is to control a Smart Car with an analog Joystick. In the following Instructables I will show you more interesting and complex robot designs, so stay tuned ;-)
Please note that the annotation on some of the pictures in this Instructable will work correctly on some browsers only after you click on the image to expand it.
Please make sure you click on the image to see the annotation showing the correct spot on the image!
Step 1: Components
- One Smart Car chassis with 2 DC motors, gears and wheels
- One Arduino board (I used Arduino UNO, but any other will be just fine)
- One L298N Dual Motor Driver Module
- One Joystick that I got from this cheap 37 sensors set
- One USB Power supply with USB Cable (I used a USB Power Bank but any other option will work)
- 2 Male-Male jumper wires
- 8 Female-Male jumper wires
Step 2: Connect the Joystick to Arduino
- Connect Female-Female wires to the Ground(Black wire), Power(Red wire), VRx(Brown wire), and VRy(Orange wire) of the Joystick as shown in Picture 1
- Connect the VRx wire(Brown wire) the the Analog 1 pin of the Arduino board (Picture 2)
- Connect the VRy wire(Orange wire) the the Analog 0 pin of the Arduino board (Picture 2)
- Connect the Ground wire(Black wire) to the Ground pin of the Arduino board (Picture 2)
- Connect the Power wire(Red wire) to the 5V(Called IOREF on most boards) Power pin of the Arduino board (Picture 2)
- Picture 3 shows the Arduino Uno pins that were connected in this step
Step 3: Connect the Motors to the L298N Motor Driver Board
- Connect the wires from one of the motors to the OUT1 and OUT2 Motor Control pins of the L298N Motor Driver Module (Picture 1)
- Connect the wires from one of the motors to the OUT3 and OUT4 Motor Control pins of the L298N Motor Driver Module (Picture 2)
- Pictures 3 shows the connected wires to the L298N Motor Driver Module
- Picture 4 shows the other end of the wires connected to the Motors and the 0.1uF anti-sparkingcapacitors soldered to the Motors as shown in this Instructable
Step 4: Connect Power to the L298N Motor Driver Board
- Connect Male-Male Power wire(Red wire) to the +12V Power Pin of the L298N Motor Driver Module (Picture 1 and 2)
- Connect Male-Male Ground wire(Black wire) to the Ground Pin of theL298N Motor Driver Module (Picture 1 and 2)
- Connect the other end of the Ground wire(Black wire) to the Ground Pin of the Arduino board (Picture 3)
- Connect the other end of the Power wire(Red wire) to the 5V Power Pin of the Arduino board (Picture 3)
- Picture 4 shows in Red the Arduino Uno pins that were connected in this step. In Blue are shown the connections done in the previous steps
Step 5: Connect the L298N Motor Driver Board Control Pins to Arduino
- Leave the ENA and ENB jumpers on the L298N Motor Driver Module (Picture 1)
- Connect the Female end of a Female-Male wire(Control 1)(Purple wire) to the IN1 pin of the L298N Motor Driver Module (Picture 1)
- Connect the Female end of a Female-Male wire(Control 2)(Blue wire) to the IN2 pin of theL298N Motor Driver Module (Picture 1)
- Connect the Female end of a Female-Male wire(Control 3)(Green wire) to the IN3 pin of theL298N Motor Driver Module (Picture 1)
- Connect the Female end of a Female-Male wire(Control 4)(Yellow wire) to the IN4 pin of the L298N Motor Driver Module (Picture 1)
- Connect the other end of the Control 1 wire(Purple wire) to the Digital 2 Pin of the Arduino board (Picture 2)
- Connect the other end of the Control 2 wire(Blue wire) to the Digital 3 Pin of the Arduino board (Picture 2)
- Connect the other end of the Control 3 wire(Green wire) to the Digital 4 Pin of the Arduino board (Picture 2)
- Connect the other end of the Control 4 wire(Yellow wire) to the Digital 5 Pin of the Arduino board (Picture 2)
- Picture 3 shows in Red the Arduino Uno pins that were connected in this step. In Blue are shown the connections done in the previous steps
Step 6: Add Power and Secure the Lose Components to the Car Chassis
- Add a USB power source (In my case a rechargeable USB power bank) (Picture 1)
- Use straps, rubber bands, screws or any other convenient ways to secure the wires and boards to the chassis (Pictures 1, 2 and 3)
Step 7: Start Visuino, and Add Steering Differential, and Motor Driver Bridge Components
To start programming the Arduino, you will need to have the Arduino IDE installed from here: http://www.arduino.cc/.
Please be aware that there are some critical bugs in Arduino IDE 1.6.6.
Make sure that you install 1.6.5 or 1.6.7, otherwise this Instructable will not work!
The Visuino: https://www.visuino.com also needs to be installed.
- Start Visuino as shown in the first picture
- Type "steer" in the Filter box of the Component Toolbox then select the "Steering Differential" component (Picture 1), and drop it in the design area.
This component will calculate the speed of the left and right motors based on the Speed and Direction from the Joystick (X and Y control) - Type "motor" in the Filter box of the Component Toolbox then select the "Dual DC Motor Driver 2 Pin Bridge (L9110S, L298N)" component (Picture 2), and drop it in the design area
Since we left the ENA and ENB jumpers on the L298N Motor Driver module, we will control it with only 2 pins per motor. Visuino also includes a component to control it with the 3 pins, if the jumpers are disconnected, but this is not necessary
Step 8: In Visuino: Connect the Steering Differential Component
- Connect the Out" pin of "Digital[ 14 ]/AnalogIn[ 0 ]" channel of the Arduino component to the "Direction" input pin of the Steering1 component (Picture 1)
- Connect the "Out" pin of "Digital[ 15 ]/AnalogIn[ 1 ]" channel of the Arduino component to the "Speed" input pin of the Steering1 component (Picture 2)
- Connect the "Left" pin of the "Motors" pin list of the Steering1 component to the "In" pin of the "Motors[ 0 ]" channel of the DualMotorDriver1 component (Picture 3)
- Connect the "Right" pin of the "Motors" pin list of the Steering1 component to the "In" pin of the "Motors[ 1 ]" channel of the DualMotorDriver1 component (Picture 4)
Step 9: In Visuino: Connect the Motor Driver Bridge Component
- Connect the "Direction(B)" output pin of the "Motors[ 0 ]" channel of the DualMotorDriver1 component to the "Digital" input pin of "Digital[ 2 ]" channel of the Arduino component (Picture 1)
- Connect the "Speed(A)" output pin of the "Motors[ 0 ]" channel of the DualMotorDriver1 component to the "Analog" input pin of "Digital[ 3 ]" channel of the Arduino component (Picture 2)
- Connect the "Direction(B)" output pin of the "Motors[ 1 ]" channel of the DualMotorDriver1 component to the "Digital" input pin of "Digital[ 4 ]" channel of the Arduino component (Picture 3)
- Connect the "Speed(A)" output pin of the "Motors[ 1 ]" channel of the DualMotorDriver1 component to the "Analog" input pin of "Digital[ 5 ]" channel of the Arduino component (Picture 4)
Step 10: Generate, Compile, and Upload the Arduino Code
- In Visuino, Press F9 or click on the button shown on Picture 1 to generate the Arduino code, and open the Arduino IDE
- In the Arduino IDE, click on the Upload button, to compile and upload the code (Picture 2)
Step 11: And Play...
Congratulations! You have completed the project.
The Video shows the connected and powered up Smart Car.
If you connect the Power to the Arduino board, you can use the Joystick to control the car by moving the Joystick forward and backward the car will move in the Forward or Backward direction, and moving the Joystick left and right will make the car turn left and right.
If the car is not moving as expected, you may need to swap the wires controlling the motors connected in Step 3 to make them rotate in the proper direction.
On the Picture you can see the complete Visuino diagram.
Also attached is the Visuino project, that I created for this Instructable. You can download and open it in Visuino: https://www.visuino.com

Participated in the
Raspberry Pi Contest 2016
31 Comments
4 years ago
I did this project. But some function are not working properly. Reverse is not working. And while taking left turn right motor's are not running anticlockwise. Can you help me, I'm using 12v geared motors, Arduino uno, l298n.
Question 5 years ago on Introduction
What is the program to run the car if there are two motor drivers
Answer 5 years ago
You control it directly with the Joystick in this project :-)
6 years ago
Thank you for the instructable. I wired and uploaded the code, but am not getting any motor movement. I am using an ELEGOO UNO R3, so I'm not sure if that is affecting it instead of using the Arduino UNO. Please let me know if you can help.
Thanks
Reply 6 years ago
This should work almost exactly the same with ELGOO :-) . I will try to post a tutorial one of this days, if the time permits...
6 years ago
Thanks to know me that visuino program. great work
Reply 6 years ago
You are Welcome! Enjoy :-)
6 years ago
hello,
I really appreciate your work, nicely done. i have few queries as well, can we add obstacle avoiding feature by adding ultrasonic sensor in this Smart Car Robot using Visuino, how to make connection in this case and how to specify distance in Visuino. thanks in advance
Reply 6 years ago
Thank you! I am already preparing such tutorial as well as number of other tutorials, so stay tuned ;-) . If I am not mistaken, I already sent you project over e-mail earlier today ;-)
Reply 6 years ago
Yes Boian. :-)
6 years ago
nice work .
what about if i want use 4 motor what should i do in Visuino???
6 years ago
were is the codeing ?
Reply 6 years ago
The coding is done by creating Visuino design. Visuino generates the code automatically.
7 years ago
Thank you so much for such brilliant idea. I saw another motor car control using Arduino compatible platform and control through cellphone using wifi. (http://www.amebaiot.com/en/ameba-arduino-amebamotors-mobile/)
Reply 7 years ago
Thank you!
I also posted one doing remote control over WiFi with Wii controller and 2 ESP8266 ;-)
https://www.instructables.com/id/ESP8266-and-Visuin...
Probably will also post one with Bluetooth LE and Arduino 101 soon ;-) Will see...
7 years ago
Good
Reply 7 years ago
Thank you! :-)
7 years ago
It can work with a motor shiel Monster or only works with the L298N?
Reply 7 years ago
I don't have it and can't test, but the Sparkfun site lists it as Full Bridge, and according to this, and from the schematics, it should work :-) . Let me know if you have problems with it, and I can take a further look.
Reply 7 years ago
I tried the code with the monster bridge but It didn't work, I mean the monster bridge uses two direction signals and one pwm. How can I modify the visuino code to do that?