IR Controlled Car

by Splat in Circuits > Robots

1065 Views, 15 Favorites, 0 Comments

IR Controlled Car

DSCF3557-PhotoRoom.png-PhotoRoom.png

This is a simple IR controlled car built with an Arduino Nano and a HG7881 motor driver. It has two geared drive motors and can be controlled with a TV remote. It runs on two 3.7v Li ion 18650 batteries, one for the Arduino Nano and one for the motor driver which last for a very long time.

Supplies

DSCF3430.JPG
DSCF3431.JPG
DSCF3433.JPG
DSCF3434.JPG
DSCF3435.JPG
DSCF3436.JPG
DSCF3437.JPG
DSCF3438.JPG
DSCF3439.JPG
DSCF3441.JPG
DSCF3455.JPG
DSCF3456.JPG
DSCF3443.JPG
DSCF3444.JPG
DSCF3445.JPG
DSCF3446.JPG
DSCF3447.JPG
DSCF3548.JPG
DSCF3545.JPG

Parts Required.

  1. Arduino Nano and programming cable 1x
  2. HG7881 motor driver 1x
  3. Switch 1x
  4. Geared motors and wheels 2x
  5. 400 pin breadboard 1x
  6. + battery terminals 2x
  7. - battery terminals 2x
  8. Male to female jumper wires 9x
  9. 3D printed parts
  10. M2 washer 2x
  11. M4 washer 2x
  12. M2 bolt 2x
  13. M2 nut 2x
  14. IR receiver 1x
  15. Male to male jumper wires 2x
  16. 3.7v Li ion 18650 batteries 2x

Tools Required.

  1. Soldering iron
  2. Glue gun
  3. 3D printer

Software Required

  1. Arduino IDE
  2. Cura or some other 3D printing software.

3D Printing the Parts.

DSCF3454.JPG
DSCF3455.JPG
DSCF3456.JPG
DSCF3457.JPG

The first step is to print the parts for the robot. I printed parts 2 and 3 with a resolution of .10 mm and the rest of the parts with a resolution of .20 mm.

Attaching the Motors and the Motor Driver.

DSCF3454.JPG
DSCF3458.JPG
DSCF3459.JPG
DSCF3460.JPG
DSCF3464.JPG
DSCF3465.JPG
DSCF3466.JPG
DSCF3468.JPG
DSCF3478.JPG

In this step we will attach the motors and the motor driver. Use the M2 bolts, nuts, and washers to attach the motor driver to the frame of the robot. If your motor driver doesn't have holes or they don't line up you can glue it down. I also glued the motor wires to the frame so they wouldn't be in the way.

Attaching the Breadboard.

DSCF3472.JPG
DSCF3473.JPG
DSCF3474.JPG
DSCF3475.JPG
DSCF3476.JPG
DSCF3477.JPG

Now we will attach the Arduino Nano and the breadboard to the main part of the robot.

Stick the Arduino Nano onto the breadboard and then plug in the jumper wires. If you don't have solid core wire you can always use flexible jumper wires or just wire.

The Battery Terminals.

DSCF3481.JPG
DSCF3482.JPG
DSCF3483.JPG
DSCF3485.JPG
DSCF3486.JPG
DSCF3490.JPG
DSCF3491.JPG
DSCF3492.JPG
DSCF3493.JPG
DSCF3494.JPG
DSCF3495.JPG
DSCF3499.JPG

Next we will attach the battery terminals and the switch then plug it all in to the breadboard.

First get four battery terminals (two positive and two negative) and solder wires onto them. Then slide the negative terminals into place on the right side of the battery pack and plug one wire into the negative part of the left power rail and the other one on the negative part of the right power rail.

For the positive terminals solder the two ends of the wire together and then solder the switch on. Next get two wires and solder them onto the other pin of the switch. Then glue the switch onto the robot body and plug one of the pins into the Vin pin of the Arduino nano and the other into the positive part of the power rail by the battery pack.

The Motor Driver Wires.

DSCF3500.JPG
DSCF3501.JPG
DSCF3503.JPG
DSCF3504.JPG
DSCF3505.JPG
DSCF3506.JPG
DSCF3512.JPG
DSCF3509.JPG

In this step we will attach the wires for the motor driver.

Get six male to female jumper wires and plug them into the motor driver as shown. then attach the other ends of the wires to the Arduino Nano. After that use electrical tape to wrap up the wires.

  • Green goes to pin 9
  • Blue goes to pin 10
  • Gray goes to the + side of the power rail by the battery pack.
  • Purple goes to the - side of the power rail by the battery pack.
  • White goes to pin 12
  • Black goes to pin 11

After that use electrical tape to wrap up the wires.

The IR Receiver

DSCF3510.JPG
DSCF3511.JPG
DSCF3514.JPG
DSCF3524.JPG
DSCF3515.JPG
DSCF3522.JPG
DSCF3525.JPG

In this step we will attach the IR receiver.

Get three male to female jumper wires and attach them to the IR receiver as shown. Then tape or glue it to the part in the front of the robot and plug in the wires.

  • Black goes to the - side of the power rail by the motor driver.
  • red goes to the + side of the power rail by the motor driver.
  • Brown goes to pin 8

Then use tape to wrap up the wires and glue them to the robot body.


The Front and Back Wheels.

DSCF3526.JPG
DSCF3527.JPG
DSCF3528.JPG
DSCF3532.JPG
DSCF3533.JPG
DSCF3534.JPG
DSCF3535.JPG
DSCF3536.JPG
DSCF3537.JPG
DSCF3540.JPG
DSCF3541.JPG
DSCF3542.JPG
DSCF3543.JPG
DSCF3544.JPG

Now we will attach the front and back wheels.

Get the wheels for the geared motors and slide them on to the geared motors.

For the front wheel get one of the wheel support with the pin and put an M4 washer on it. Then put the 3D printed wheel on top of it. Next put another M4 washer on top and put the other wheel support on top. Then stick it in the holes in the front of the robot.


The Code.

DSCF3545.JPG
DSCF3546.JPG
IR_decoder_screenshot.PNG
IR_decoder_screenshot1.PNG

In this step we will upload the code to the robot

Before we upload the code we need to find the code of the remote. first upload the IR decoder code to the robot and push a button on the remote and the code to that button will show in the serial monitor. If you want the robot to go forward when the up button of the remote is pushed, use the decoder to decode that button then copy the top number sequence from the serial monitor to the line of code that makes the robot go forward.

Example.

 switch (results.value) {

  case 752:// This is the number the decoder showed when I pushed the up button. It will be different on your remote.

  Serial.println("up");

  digitalWrite(M1pin1, LOW);

  digitalWrite(M1pin2, HIGH);

  digitalWrite(M2pin1, HIGH);

  digitalWrite(M2pin2, LOW);

  break;

  }

I hope this makes sense to you. If not please leave a comment and I will try to explain it to you better.



Testing the Robot.

DSCF3548.JPG
DSCF3549.JPG
DSCF3550.JPG

Now we will test the robot.

Get the batteries for the robot and put them in with the + on one side and the - on the other.( The + goes on the springs.) Then turn on the switch and the motor driver LED and the Arduino LED should turn on. Then push one of the buttons that you have programmed in to the robot and it should respond to it.

Have Fun!


Troubleshooting.

DSCF3561-PhotoRoom.png-PhotoRoom.png

If your robot is not working try doing some of these things things to fix it.

  1. If the robot is turning right when you want it to go forward switch the white and black wires around.
  2. if the robot is turning left when you want it to go forward switch the green and blue wires around.
  3. if the robot is going backwards when you want it to go forward switch the green and blue wires around and switch the black and white wires around.
  4. if the motor driver light is dimming a lot and the robot is not moving recharge the batteries.
  5. if the motor driver light is not lighting up switch the battery that goes to the motor driver around.
  6. if the robot is not responding to the remote try using a different remote.
  7. if the code is not uploading make sure that the processor is switched to the ATmega328P(Old Bootloader) if your Arduino Nano you are using was made before 2018. If it was made after 2018, switch it to ATmega328P.
  8. if the front wheel is falling off glue the part that is falling off together.

If you have any more problems please leave a comment below.