Arduino car and controller - code to make your own

Controller:

const int accel(0);
const int steer(1);

void setup() {
  // SETUP CODE:
  Serial.begin(9600);
}

void loop() {
  // MAIN CODE:
  int accelVal(map(analogRead(accel), 0, 1023, -255, 255));
  int steerVal(map(analogRead(steer), 0, 1023, 45, 135));

  Serial.print(accelVal);
  Serial.print(",");
  Serial.println(steerVal);
}

Car:

#include <Servo.h>

Servo steering;

const int motorF(11);
const int motorB(10);

void setup() {
  // SETUP CODE:
  Serial.begin(9600);

  pinMode(motorF, OUTPUT);
  pinMode(motorB, OUTPUT);

  steering.attach(9);
}

void loop() {
  // MAIN CODE:
  if (Serial.available()) {
    String values(Serial.readStringUntil('\n'));

    values.trim();

    char vals[10];

    values.toCharArray(vals, 10);

    int accel(atoi(strtok(vals, ",")));
    int steer(atoi(strtok(NULL, ",")));

    if (accel < 0) {
      accel = 0 - accel;
      
      analogWrite(motorF, 0);
      analogWrite(motorB, accel);
    } else if (accel == 0) {
      analogWrite(motorF, 0);
      analogWrite(motorB, 0);
    } else {
      analogWrite(motorF, accel);
      analogWrite(motorB, accel);
    }

    steering.write(steer);
  }
}

Parts:

Receiver:
Servo motor (x1)

DC motor (any quantity will work; use a double shaft motor if using only one motor)

HC-05 Bluetooth module.

L293D motor driver

Transmitter:

X-axis 1-dimensional joystick

Y-axis 1-dimensional joystick

HC-05 Bluetooth module

Note: You can use a single 2-dimensional joystick, but the two 1-dimensional joystick configuration is recommended for a better user experience.

To make the car, make sure you give forward motor output by connecting pin 11, and give backward motor output with pin 10 to the motor driver. Connect the motor(s) to the driver to spin in two directions. You can use a setup with more motors in parallel, though a single motor setup, utilizing a double-shaft motor, is recommended. Connect your servo motor to pin 9, and make sure that 90 degrees on the servo motor corresponds to the wheels of the car pointing straight ahead. Connect the HC-05 Bluetooth module’s RX to the TX of the Arduino, and the TX to the RX of the Arduino. Additionally, for safety, you can opt to add a voltage divider to safely operate the HC-05 with a 1kΩ resistor between the Arduino TX and HC-05 RX, and a 2kΩ resistor between the HC-05 RX and the ground.

To make the controller, hook up the Y-axis to analog pin 0, and the X-axis to analog pin 1, and in the same manner from above, connect the HC-05 to the Arduino, and make sure everything is grounded properly.

Additionally, make sure that the two HC-05 Bluetooth modules are paired in a master-slave configuration.

Happy building!

NO NO NO

Draw the wiring diagram and label everything then take a picture and post.

What car?

It’s just a mini toy car with a controller that you can make.

Here are two ASCII circuit schematics:

Car:

                              +5V
                               |
                               |
                              .-.
                              | | (Power Bus)
                              '-'
                               |
                               |                               +---------------------+
                               |                               |     HC-05 Module    |
                               |      +----------------------+  |                     |
                               |      |      Arduino UNO     |  | RX <----/\/\--+-- TX|
                               |      |                      |  |         1kΩ   |     |
                               |      | [5V]-----------------+--+--------------+     |
                               |      | [GND]----------------+-----------------+-----+
                               |      | [TX]----/\/\----+---------------------------+
                               |      |        1kΩ       |
                               |      |                  +--/\/\--> GND
                               |      |                     2kΩ
                               |      | [RX]<-------------------- TX (HC-05)
                               |      | [D9] ---> Servo Signal
                               |      | [D10]--> IN2 (L293D)
                               |      | [D11]--> IN1 (L293D)
                               |      +----------------------+
                               |                             |
                               |                             |
                              GND                           GND
                               |                             |
                               |                             |
                               +----------------+-------------+
                                                |
                                                |
                                                v
                                     +---------------------+
                                     |  L293D Motor Driver |
                                     |---------------------|
                                     | IN1 <--- D11        |
                                     | IN2 <--- D10        |
                                     | ENA ---> +5V (jumper)|
                                     | OUT1 ---> Motor +    |
                                     | OUT2 ---> Motor -    |
                                     | Vcc1 ---> +5V        |
                                     | Vcc2 ---> +9V ext.   |
                                     | GND ----> GND        |
                                     +---------------------+
                                                |
                                                v
                                             (MOTOR)
                                                |
                                               GND

                               +5V
                                |
                                |
                                +----------------+
                                |                |
                                |          +------------+
                                |          | Servo Motor|
                                |          | Sig -> D9  |
                                |          | +V -> 5V   |
                                |          | GND -> GND |
                                |          +------------+
                                |
                               GND

Controller:

                               +5V
                                |
                                |
                              .-.
                              | | (Power Bus)
                              '-'
                                |
                                |                              +---------------------+
                                |                              |     HC-05 Module    |
                                |      +----------------------+ |                     |
                                |      |   Arduino UNO/Nano   | | RX <----/\/\--+-- TX|
                                |      |                      | |         1kΩ   |     |
                                |      | [5V]-----------------+-+--------------+     |
                                |      | [GND]----------------+----------------+-----+
                                |      | [A0] <--- Joystick Y-Axis                 |
                                |      | [A1] <--- Joystick X-Axis                 |
                                |      | [TX]----/\/\----+-------------------------+
                                |      |        1kΩ       |
                                |      |                  +--/\/\--> GND
                                |      |                     2kΩ
                                |      | [RX]<-------------------- TX (HC-05)
                                |      +----------------------+
                                |                             |
                               GND                           GND
                                |                             |
                                |                             |
                                +---------------+--------------+
                                                |
                                                |
                                                v
                                       +------------------+
                                       | Joystick Module  |
                                       |------------------|
                                       | VRx -> A1        |
                                       | VRy -> A0        |
                                       | +5V -> 5V        |
                                       | GND -> GND       |
                                       +------------------+

Sorry but...

Can you please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.

Also some images of your project.

Tom.... :smiley: :+1: :coffee: :australia: