Introduction: Program Infrared Remote Controlled Arduino Smart Car Robot With Visuino

Recently I received a Smart Car Robot Kit donated by Elegoo for the Visuino development, and I already posted a Tutorial on how to assemble the Kit.

Here I will show you how easy it is to program the Robot with Visuino so you can control it with Infrared Remote.

Step 1: Components

One assembled Elegoo Smart Car Robot car and the Infrared Remote included in the kit (Picture 1)

Pictures 2, and 3 show the unassembled kit.

Here is a Tutorial on how to assemble the robot.

Step 2: Start Visuino, and Add Motor Driver Bridge Component

To start programming the Arduino, you will need to have the Arduino IDE installed from here: http://www.arduino.cc/.

Make sure that you install 1.6.7 or higher, otherwise this Instructable will not work!

The Visuino: https://www.visuino.com also needs to be installed.

  1. Start Visuino as shown in the Picture
  2. Type "motor" in the Filter box of the Component Toolbox then select the "Dual DC Motor Driver 3 Pin Bridge(L298N)" component (Picture), and drop it in the design area

Step 3: In Visuino: Connect the Motor Driver Bridge Component

  1. Connect the "Forward" output pin of the "Motors[ 0 ]" channel of the DualMotorDriver1 component to the "Digital" input pin of "Digital[ 7 ]" channel of the Arduino component (Picture 1)
  2. Connect the "Reverse" output pin of the "Motors[ 0 ]" channel of the DualMotorDriver1 component to the "Digital" input pin of "Digital[ 6 ]" channel of the Arduino component (Picture 2)
  3. Connect the "Speed" output pin of the "Motors[ 0 ]" channel of the DualMotorDriver1 component to the "Analog" input pin of "Digital[ 5 ]" channel of the Arduino component (Picture 5)
  4. Connect the "Forward" output pin of the "Motors[ 1 ]" channel of the DualMotorDriver1 component to the "Digital" input pin of "Digital[ 8 ]" channel of the Arduino component (Picture 1)
  5. Connect the "Reverse" output pin of the "Motors[ 1 ]" channel of the DualMotorDriver1 component to the "Digital" input pin of "Digital[ 9 ]" channel of the Arduino component (Picture 2)
  6. Connect the "Speed" output pin of the "Motors[ 1 ]" channel of the DualMotorDriver1 component to the "Analog" input pin of "Digital[ 10 ]" channel of the Arduino component (Picture 5)

Step 4: In Visuino: Add, Configure, and Connect 2 "Ramp to Value" Components

You can control the motor speeds directly, however if you suddenly change the motor from stopped to full speed, or from full speed to stop, this will make the robot movements "jumpy", and may lead to wheels easily detaching from the robot. It is better to speed up and slow down the motors gradually using a ramp. Visuino includes "Ramp To Value" component designed for such purpose.

  1. Type "ramp" in the Filter box of the Component Toolbox then select the "Ramp To Value" component (Picture 1), and drop 2 of them in the design area
  2. Select the 2 "Ramp To Value" components (Picture 2)
  3. In the Object Inspector, set the value of the "Initial Value" property to "0.5" (Picture 2) - this specifies that the motors will initially be off
  4. In the Object Inspector, set the value of the "Slope" property to "2" (Picture 3) - this will specify how fast the motors will ramp up and down
  5. Connect the "Out" output pin of the RampToValue1 component to the "In" input pin of the "Motors[ 0 ]" channel of the DualMotorDriver1 component (Picture 4)
  6. Connect the "Out" output pin of the RampToValue2 component to the "In" input pin of the "Motors[ 1 ]" channel of the DualMotorDriver1 component (Picture 5)

Step 5: In Visuino: Add "Analog Value" Component, and Add 4 "Set Value State" Elements

To control the motor speeds for the 4 commands from the remote (Forward, Backward, Left, and Right), and the Stop, we can use "Analog Value" component for each motor with value 0.5 - Stop, and 4 "Set Value State" elements specifying the motor speeds for the 4 commands.

  1. Type "analog value" in the Filter box of the Component Toolbox then select the "Analog Value" component (Picture 1), and drop it in the design area
  2. In the Object Inspector set the value of the "Value" property of the AnalogValue1 component to "0.5" (Picture 2) - this will make sure the motor is off by default
  3. Click on the "Tools" button of the AnalogValue1 component to open the "Elements" dialog (Picture 3)
  4. In the "Elements" editor select the "Set Value State" in the right window, and clicking on the "+" button 4 times (Picture 4) to add 4 of them
  5. In the Elements Editor select the "Set Value State1" (Picture 5)
  6. In the Object Inspector set the value of the "Value" property of the element to "1" (Picture 2) - this will specify the motor to rotate forward
  7. In the Elements Editor select the "Set Value State2" (Picture 6)
  8. In the Object Inspector set the value of the "Value" property of the element to "1" (Picture 3)
  9. Leave the other 2 Elements unchanged. The value of the "Value" property for them will be "0" - this will specify the motor to rotate backward
  10. Close the "Elements" editor

Step 6: In Visuino: Add Another "Analog Value" Component, and Add 4 "Set Value State" Elements

  1. Type "analog value" in the Filter box of the Component Toolbox then select the "Analog Value" component (Picture 1), and drop it in the design area
  2. In the Object Inspector set the value of the "Value" property of the AnalogValue1 component to "0.5" (Picture 2)
  3. Click on the "Tools" button of the AnalogValue1 component to open the "Elements" dialog (Picture 3)
  4. In the "Elements" editor select the "Set Value State" in the right window, and clicking on the "+" button 4 times (Picture 4) to add 4 of them
  5. In the Elements Editor select the "Set Value State1" (Picture 5)
  6. In the Object Inspector set the value of the "Value" property of the element to "1" (Picture 2)
  7. In the Elements Editor select the "Set Value State4" (Picture 6)
  8. In the Object Inspector set the value of the "Value" property of the element to "1" (Picture 3)
  9. Leave the other 2 Elements unchanged
  10. Close the "Elements" editor

Step 7: In Visuino: Connect the 2 "Analog Value" Components

  1. Connect the "Out" output pin of the AnalogValue1 component to the "In" input pin of the RampToValue1 component (Picture 1)
  2. Connect the "Out" output pin of the AnalogValue2 component to the "In" input pin of the RampToValue2 component (Picture 2)

Step 8: In Visuino: Add Infrared Receiver Component, and Add 4 Decode NEC Command Elements to It

To decode the infrared commands, we will add Infrared Receiver component. The simplest way to decode a specific command is to add Decode element to the Infrared Receiver Elements: We will add 4 such elements for the 4 commands - Forward, Back, Left and Right.

  1. Type "infra" in the Filter box of the Component Toolbox then select the "Infrared Receiver" component (Picture 1), and drop it in the design area
  2. Click on the "Tools" button of the InfraredReceiver1 component to open the "Elements" dialog (Picture 2)
  3. In the "Elements" editor select the "Decode NEC Command" in the right window, and clicking on the "+" button 4 times (Picture 3) to add 4 of them

Step 9: In Visuino: Configure the 4 Decode NEC Command Elements

  1. In the Elements Editor select the 4 Decode NEC Command elements (Picture 1)
  2. In the Object Inspector set the value of the "Repeat Interval" property of the element to "200" (Picture 1)
  3. In the Elements Editor select the "Decode NEC Command1" (Picture 2)
  4. In the Object Inspector set the value of the "Value" property of the element to "16736925" (Picture 2) - This will specify the Infrared button code. You can follow this tutorial to discover the codes for each button of your remote
  5. In the Elements Editor select the "Decode NEC Command2" (Picture 3)
  6. In the Object Inspector set the value of the "Value" property of the element to "16761405" (Picture 3)
  7. In the Elements Editor select the "Decode NEC Command3" (Picture 4)
  8. In the Object Inspector set the value of the "Value" property of the element to "16754775" (Picture 4)
  9. In the Elements Editor select the "Decode NEC Command4" (Picture 5)
  10. In the Object Inspector set the value of the "Value" property of the element to "16720605" (Picture 5)
  11. Close the "Elements" editor

Step 10: In Visuino: Connect the First 2 Decode NEC Command Elements

  1. Connect the "Out" output pin of the "Elements.Decode NEC Command1" element of the InfraredReceiver1 component to the "In" input pin of the "Elements.Set Value State1" of the AnalogValue1 component (Picture 1)
  2. Connect the "Out" output pin of the "Elements.Decode NEC Command1" element of the InfraredReceiver1 component to the "In" input pin of the "Elements.Set Value State1" of the AnalogValue2 component (Picture 2)
  3. Connect the "Out" output pin of the "Elements.Decode NEC Command2" element of the InfraredReceiver1 component to the "In" input pin of the "Elements.Set Value State2" of the AnalogValue1 component (Picture 3)
  4. Connect the "Out" output pin of the "Elements.Decode NEC Command2" element of the InfraredReceiver1 component to the "In" input pin of the "Elements.Set Value State2" of the AnalogValue2 component (Picture 4)

Step 11: In Visuino: Connect the Rest of the Decode NEC Command Elements, and the Infrared Receiver Component

  1. Connect the "Out" output pin of the "Elements.Decode NEC Command3" element of the InfraredReceiver1 component to the "In" input pin of the "Elements.Set Value State3" of the AnalogValue1 component (Picture 1)
  2. Connect the "Out" output pin of the "Elements.Decode NEC Command3" element of the InfraredReceiver1 component to the "In" input pin of the "Elements.Set Value State3" of the AnalogValue2 component (Picture 2)
  3. Connect the "Out" output pin of the "Elements.Decode NEC Command4" element of the InfraredReceiver1 component to the "In" input pin of the "Elements.Set Value State4" of the AnalogValue1 component (Picture 3)
  4. Connect the "Out" output pin of the "Elements.Decode NEC Command4" element of the InfraredReceiver1 component to the "In" input pin of the "Elements.Set Value State4" of the AnalogValue2 component (Picture 4)

Step 12: Generate, Compile, and Upload the Arduino Code

  1. In Visuino, Press F9 or click on the button shown on Picture 1 to generate the Arduino code, and open the Arduino IDE
  2. In the Arduino IDE, click on the Upload button, to compile and upload the code (Picture 2)

If you get compiler error in the Arduino IDE, this means that you are missing the following library:

https://github.com/z3t0/Arduino-IRremote

Look at this Tutorial to see how to install it!

Step 13: And Play...

Congratulations! You have a full Infrared Remote control over your Smart Car Robot.

If you power up the Smart Car Robot, you can control it by pressing on the Arrow buttons of the Infrared Remote as shown on the Video.

On the Picture you can see the complete Visuino diagram.

Also attached are the Visuino projects, that I created for this Tutorial. You can download and open them in Visuino: https://www.visuino.com

Comments

author
MichaelS1328 made it! (author)2017-06-06

Hi,

now it´s give a new version "V2.0" of the Smart Car Robot!

It comes with some changes!

author
BoianM made it! (author)BoianM2017-06-06

Hi MichaelS1328,
Yes, I have already posted some videos on the 2.0 robot. Will see to post instructables too soon :-)

https://www.youtube.com/playlist?list=PLymDIvwzJQlseAGSoKxOd3bKnU68ry5An

author
MichaelS1328 made it! (author)MichaelS13282017-06-07

Hi BoianM,

it is a nice project with the 2.0 Robot and the new elegoo board!

Thank you for your fantastic work with the many tutorials and the clips on youtube.

author
yousefalkayyali made it! (author)2017-02-27

how can I switch it to drive alone without the control of the remote?

author
BoianM made it! (author)BoianM2017-02-28

I plan such tutorial too... just so short on time :-( . It will come soon.