Making of RC Car using Arduino

How to build a RC Car using Arduino and Motor Driver


Category: Arduino Tags: Radio Receiver, Radio Transmitter, L293D Motor Driver, DC Motor

RC Car - Code Files

In this article we will learn how to make a RC Car using Arduino:

Prerequisites:

  1. Arduino UNO with cable
  2. L293D Motor Driver
  3. Car Frame Kit
  4. Flysky Radio Receiver
  5. Flysky Radio Transmitter
  6. Batteries

Libraries used:

  1. AFMotor - For Motor Shield
  2. IBusBM - For Flysky Receiver
L293D Motor Driver Shield
Fig 1: L293D Motor Driver Shield

 

Caution-   Remove jumper PWR if providing additional power supply to Arduino rather than taking power from shield.

Implementation

   We have to connect components as described in imaghe above. Code is given below which you will have to upload to Arduino.

#include <AFMotor.h>
#include <IBusBM.h>
IBusBM ibus;

AF_DCMotor motor1(1, MOTOR12_64KHZ);
AF_DCMotor motor2(2, MOTOR12_64KHZ);
AF_DCMotor motor3(3, MOTOR12_64KHZ);
AF_DCMotor motor4(4, MOTOR12_64KHZ);

void setup() {
Serial.begin(115200);
ibus.begin(Serial);
motor1.setSpeed(200);
motor2.setSpeed(200);
motor3.setSpeed(200);
motor4.setSpeed(200);
}

void loop() {

double ch1Value = readChannel(0, -100, 100, 0);
double ch2Value = readChannel(1, -100, 100, 0);

if((ch1Value==0)&&(ch2Value==0))
{
motor1.run(RELEASE);
motor2.run(RELEASE);
motor3.run(RELEASE);
motor4.run(RELEASE);
}
if((ch1Value<30)&&(ch2Value<-50))
{
motor1.run(FORWARD);
motor3.run(FORWARD);
motor2.run(FORWARD);
motor4.run(FORWARD);
}
else if((ch1Value<30)&&(ch2Value>50))
{
motor1.run(BACKWARD);
motor3.run(BACKWARD);
motor2.run(BACKWARD);
motor4.run(BACKWARD);
}
else if((ch1Value<-50)&&(ch2Value<30))
{
motor1.run(FORWARD);
motor4.run(FORWARD);
motor2.run(BACKWARD);
motor3.run(BACKWARD);
}
else if((ch1Value>50)&&(ch2Value<30))
{
motor1.run(BACKWARD);
motor4.run(BACKWARD);
motor2.run(FORWARD);
motor3.run(FORWARD);
}
else
{
motor1.run(RELEASE);
motor2.run(RELEASE);
motor3.run(RELEASE);
motor4.run(RELEASE);
}
delay(200);
}

int readChannel(byte channelInput, int minLimit, int maxLimit, int defaultValue) {
uint16_t ch = ibus.readChannel(channelInput);
if (ch < 100) return defaultValue;
return map(ch, 1000, 2000, minLimit, maxLimit);
}

Full video of Making RC car is below.

 


Like 0 People
Last modified on 13 June 2022
Nikhil Joshi

Nikhil Joshi
Ceo & Founder at Dotnetlovers
Atricles: 164
Questions: 16
Given Best Solutions: 16 *

Comments:

sandesh

which libary is used in this code please provide it

Like 0 People on 3 August 2022
Nikhil Joshi

Hi Sandesh, You can install libraries mentioned above from Arduino Library manager.

Like 0 People on 3 August 2022

You are not loggedin, please login or signup to add comments:

Existing User

Login via:

New User



x