Realistic Car Model

by 702947 in Circuits > Arduino

104 Views, 0 Favorites, 0 Comments

Realistic Car Model

71FhKveUewL._AC_UF894,1000_QL80_.jpg

This is a realistic remote-controlled car made using Arduino and an IR Receiver. I got inspired to make it through a previous car project I created, however this one is far more advanced. I looked back at previous documents I had about how to make a functional car for the basic fundamentals of this project (hardware and software), however I did extra research (videos and articles) to make it remote controlled.

I believe it can be used for entertainment purposes or educationally by teaching the basic systems of a vehicle to someone who doesn't already know. It possesses real life characteristics of a vehicle like a braking system, headlights, indicators, a horn, etc. The car itself can be upgraded to fit to someone's liking. For example, increasing the power supply to increase the speed or adding an extra motor to improve the stability and handling of the vehicle. Overall, I believe this is a project that has a versatile number of uses and purposes. Let me know what you guys think about it in the comments section.

Main Picture Link

Supplies

Components Required:

Placing Components

Screenshot 2024-01-25 193818.png

Since my car chassis, DC Motors, and IR receiver were previously put together, I did not have to worry about the assembly of these components. However, if you ordered these items separately, then you should combine them to make the body of your car. Whether that is by gluing, screwing, or taping the parts together as long as it is sturdy. Place all of the other items on the breadboards. Try to place them in a way where you can manage your space the best without making it very difficult to access certain pieces. These components include:

  • H-Bridge Chip
  • LEDs
  • Buzzer
  • Resistors
  • IR Receiver (if not already mounted)

The H-Bridge, Buzzer, and IR Receiver are placed on one breadboard while the LEDs are placed on the other one. This is because the LEDs will be used as the headlights of the car (which are always in the front) and the H-Bridge/Buzzer will be used as the engine bay area (which will be in the back; acting like a modern supercar). Put the Resistors in their corresponding spots as well (from the Buzzer and LEDs to ground). By placing the components beforehand, it makes it much simpler to place in on the car chassis and continue wiring with the Arduino.

*You should also wire the components for power and ground when needed as it can save more time.

Wiring Components to Arduino

Screenshot 2024-01-25 172538.png

The next step would then be to connect your components to the Arduino Uno. First place the Arduino and breadboards on the car chassis in a way that would make the car look good and realistic. After making sure they are all secure, start making connections between the components and the Arduino.

Connect the DC Motors to the H-Bridge (with the output pins) while also connecting 5V and ground from the Arduino into one of the H-bridge breadboard power rails as it will be needed for the H-bridge to function (in the image, we connected 5V to the left rail and the right rail will be used for the 9V Battery).

Make sure your enable pins are connected to analog pins because they will be using PWM to control the speed of the motor. Everything else can be connected to any pin (either digital or analog). Also connect your components to ground and power (if needed), making sure that the power source is from the Arduino, otherwise they will be damaged later on!

Make sure that both of the VCC pins of the H-Bridge is connected to the correct power source (VCC 1 should be connected to the 5V power rail while VCC 2 should be connected to the 9V Power Rail) as it will be using two of them (Arduino and 9V Battery). Overall, this step is for the connection of the components to the Arduino and wiring the power connections correctly.

Color Coding:

  • Green Wires - Control Pins for Right Motor
  • Blue Wires - Control Pins for Left Motor
  • Yellow Wires - Enable Pins for H-Bridge
  • Orange Wires - LED Pins
  • Purple Wire - Buzzer Pin
  • Brown Wire - Signal Pin for IR Receiver
  • Red Wires - Power or DC Motor Connection
  • Black Wires - Ground or DC Motor Connection

Setting Up the Remote Functionality

Screenshot 2024-01-25 172614.png

Below is a file of code which you will be using to make sure your remote is working with your IR Receiver. Make sure the pin number of the IR Receiver signal pin matches your circuit and the code (change the code if it does not match). After uploading correctly, you want to take your remote and press the buttons you want to use to control your car. There will be a code printed in the Serial Monitor which you will then write down somewhere else along with a label reminding you what button printed which code. We will then use this information to then program our car to function based on the remote we are using because every remote has a different code for each one of its buttons. Overall, we are just writing down the remote codes so that we can program the car accordingly to it.

Overall Code of Car

Below is a file of the complete code for your car. In the switch statement, there are comments that specify what code for what button you should copy and paste based on the previous step (remove the slashes after pasting it). Make sure that the pins you are using for each component in your circuit matches the pin numbers stated in the code (change the code if needed). Now your car is very close to finished.

Connecting 9V Battery

Screenshot 2024-01-25 182822.png
Screenshot 2024-01-25 185156.png

The last step is to connect the 9V Battery. Connect the Battery Cap to the Battery and place the red wire into the positive side of the power rail and the black wire to the negative side of the power rail (in our case, the 9V Battery power rail is on the right; stated in step 2). Then connect the grounds of each power rail to each other.

Make sure the positive side of the power rail for the Arduino and Battery are NOT connected, only the negative sides. Otherwise you will fry the device where you are plugging your Arduino into! I recommend taping the battery to the car, as it will probably fall off and the motors will stop moving.

Now upload your code into the Arduino and the car should be fully operational. Try pressing the buttons that you tested for and see if the car begins doing its corresponding action. If the wheels are moving in the wrong direction, switch the DC Motor wires in the H-Bridge (for example, if the wheels are moving backwards instead of forwards).

Common Mistakes

When making my project, I ran into various problems that I want to share with you incase, you are experiencing the same issue:

  1. Power Connection: When connecting the 9V Battery to my Car, I fried multiple devices which the Arduino was connected to because I accidentally connected the power sources of both the battery and Arduino. Remember to check that you only connect ground (Blue Columns) from both the power rails and not the VCC (red columns) as it will lead to this major problem to occur.
  2. Buttons Not Working: For some remotes, the code of certain buttons changed depending on how many times you pressed it. This can lead to your car to not respond because it doesn't recognize the new code that the remote is sending. To fix this issue, you must redo step 3 and write down the new codes that the remote is sending. Then in your program, add new cases in the switch statement that check for your new code/codes and write the functionality based on what button you are checking for. It is okay if different cases have the same block statements/functionality.
  3. Wheels Not Moving Correctly: In the beginning, your wheels may not move in the right direction as you want them too. For example, when clicking your forward button, your wheels may be moving backwards. To fix this you can do one of two things:
  • Swap the DC Motor Connections from your H-Bridge: For example, take the DC Motor wire from Output 1 and place it in Output 2 and swap the wire from Output 2 and place it in Output 1. This should fix the issue as you are now reversing the direction the wheel will move in.
  • Changing the Code: In the movement functions, you can reverse the output of the Control Pins. For example, if the code for moving forward is:

digitalWrite(CPin1, HIGH);

digitalWrite(CPin2, LOW);

digitalWrite(CPin3, HIGH);

digitalWrite(CPin4, LOW);

  • You can reverse the output of the pins to then make the wheels move in the opposite direction to then fix your problem. Your new code would then look like:

digitalWrite(CPin1, LOW);

digitalWrite(CPin2, HIGH);

digitalWrite(CPin3, LOW);

digitalWrite(CPin4, HIGH);

  • Now your wheels will move in the opposite direction which will then fix your problem. However, I prefer the first method as it is much simpler and harder to create errors with.

Overall, those were three main issues that I ran into and I hope this helps with anybody else who is experiencing the same problem.