Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino-Powered RC Tank with L298N Motor Driver and LiPo Battery

View and Edit Project In Cirkit DesignerImage of Arduino-Powered RC Tank with L298N Motor Driver and LiPo Battery

Circuit Documentation

Summary

This circuit is designed to control an RC tank using an Arduino Micro Pro, an L298N motor driver, and an RC receiver module. The Arduino receives input signals from the RC receiver and controls the motor driver to drive two DC motors. The power is supplied by a LiPo battery.

Component List

  1. LiPo Battery 2200mAH 30C

    • Description: Provides power to the circuit.
    • Pins: VCC, GND
  2. Arduino Micro Pro

    • Description: Microcontroller that processes input signals and controls the motor driver.
    • Pins: RAW, RST, VCC, A3, A2, A1, A0, 15, 14, 16, 10, 9, 8, 7, 6, 5, 4, 3, 2, GND, RX, TX
  3. L298N DC Motor Driver

    • Description: Drives the DC motors based on signals from the Arduino.
    • Pins: OUT1, OUT2, 12V, GND, 5V, OUT3, OUT4, 5V-ENA-JMP-I, 5V-ENA-JMP-O, +5V-J1, +5V-J2, ENA, IN1, IN2, IN3, IN4, ENB
  4. DC Motor

    • Description: Motors that drive the RC tank.
    • Pins: pin 1, pin 2
  5. Wire Connector

    • Description: Connects the power supply to the circuit.
    • Pins: +, -
  6. RC Receiver Module

    • Description: Receives control signals from the RC transmitter.
    • Pins: S6, S5, S4, S3, S2, S1, Vcc, GND

Wiring Details

LiPo Battery 2200mAH 30C

Arduino Micro Pro

L298N DC Motor Driver

DC Motor

Wire Connector

RC Receiver Module

Code Documentation

/*
 * RC Tank Control
 * This sketch controls an RC tank with forward, backward, and speed control.
 * The RC receiver module provides input signals to the Arduino.
 * The Arduino controls the L298N motor driver to drive the motors.
 */

// Pin definitions
const int ENA = A0;
const int ENB = A1;
const int IN1 = 2;
const int IN2 = 3;
const int IN3 = 4;
const int IN4 = 5;
const int RC_CH1 = A2; // Channel 1 from RC Receiver
const int RC_CH2 = A3; // Channel 2 from RC Receiver

void setup() {
  // Initialize motor control pins
  pinMode(ENA, OUTPUT);
  pinMode(ENB, OUTPUT);
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);
  // Initialize RC receiver input pins
  pinMode(RC_CH1, INPUT);
  pinMode(RC_CH2, INPUT);
}

void loop() {
  int ch1 = pulseIn(RC_CH1, HIGH);
  int ch2 = pulseIn(RC_CH2, HIGH);

  // Determine motor speed and direction
  int speedA = map(ch1, 1000, 2000, 0, 255);
  int speedB = map(ch2, 1000, 2000, 0, 255);

  // Forward or backward control
  if (ch1 > 1500) {
    digitalWrite(IN1, HIGH);
    digitalWrite(IN2, LOW);
  } else {
    digitalWrite(IN1, LOW);
    digitalWrite(IN2, HIGH);
  }

  if (ch2 > 1500) {
    digitalWrite(IN3, HIGH);
    digitalWrite(IN4, LOW);
  } else {
    digitalWrite(IN3, LOW);
    digitalWrite(IN4, HIGH);
  }

  // Set motor speeds
  analogWrite(ENA, speedA);
  analogWrite(ENB, speedB);
}

This code initializes the pins for motor control and RC receiver input. In the loop function, it reads the input signals from the RC receiver, maps them to motor speeds, and sets the motor direction and speed accordingly.