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

Arduino UNO IR-Controlled Robotic Car with H-Bridge and DC Motors

View and Edit Project In Cirkit DesignerImage of Arduino UNO IR-Controlled Robotic Car with H-Bridge and DC Motors

Circuit Documentation

Summary

This document provides a detailed overview of a circuit designed to control a robot using an IR remote. The circuit includes an Arduino UNO microcontroller, an H-Bridge motor driver, two DC motors, an IR receiver, and a battery pack. The Arduino UNO processes IR signals to control the motors via the H-Bridge.

Component List

  1. Arduino UNO

    • Description: A microcontroller board based on the ATmega328P.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  2. Puente H carrito

    • Description: An H-Bridge motor driver used to control the direction and speed of DC motors.
    • Pins: OUT1, OUT2, OUT3, OUT4, 12V, GND, 5V, ENA, IN1, IN2, IN3, IN4, ENB, 5VEN
  3. DC Motor (Motor 1)

    • Description: A DC motor used for driving the robot.
    • Pins: pin 1, pin 2
  4. DC Motor (Motor 2)

    • Description: A second DC motor used for driving the robot.
    • Pins: pin 1, pin 2
  5. 2x 18650 Battery Pack

    • Description: A battery pack consisting of two 18650 batteries.
    • Pins: vcc, gnd
  6. VS1838B IR Receiver

    • Description: An IR receiver module used to receive signals from an IR remote.
    • Pins: OUT, GND, VCC

Wiring Details

Arduino UNO

Puente H carrito

DC Motor (Motor 1)

DC Motor (Motor 2)

2x 18650 Battery Pack

VS1838B IR Receiver

Documented Code

/*
Sterowanie robotem za pomocą pilota IR.
*/

#include <IRremote.h>

// Definicje pinów
const int motorA1 = 9;
const int motorA2 = 8;
const int motorB1 = 5;
const int motorB2 = 4;
const int enableA = 10;
const int enableB = 3;
const int irReceiverPin = 2;

// Definicje kodów IR - Car mp3
const long IR_FORWARD = 0xB946FF00; // Przykładowy kod IR dla przycisku "Forward"
const long IR_BACKWARD = 0xEA15FF00; // Przykładowy kod IR dla przycisku "Backward"
const long IR_LEFT = 0xBB44FF00; // Przykładowy kod IR dla przycisku "Left"
const long IR_RIGHT = 0xBC43FF00; // Przykładowy kod IR dla przycisku "Right"
const long IR_STOP = 0xBF40FF00; // Przykładowy kod IR dla przycisku "Stop"

IRrecv irrecv(irReceiverPin);
decode_results results;

// Funkcje do sterowania silnikami
void moveForward() {
  digitalWrite(motorA1, HIGH);
  digitalWrite(motorA2, LOW);
  digitalWrite(motorB1, HIGH);
  digitalWrite(motorB2, LOW);
}

void moveBackward() {
  digitalWrite(motorA1, LOW);
  digitalWrite(motorA2, HIGH);
  digitalWrite(motorB1, LOW);
  digitalWrite(motorB2, HIGH);
}

void turnRight() {
  digitalWrite(motorA1, LOW);
  digitalWrite(motorA2, HIGH);
  digitalWrite(motorB1, HIGH);
  digitalWrite(motorB2, LOW);
}

void turnLeft() {
  digitalWrite(motorA1, HIGH);
  digitalWrite(motorA2, LOW);
  digitalWrite(motorB1, LOW);
  digitalWrite(motorB2, HIGH);
}

void stopMotors() {
  digitalWrite(motorA1, LOW);
  digitalWrite(motorA2, LOW);
  digitalWrite(motorB1, LOW);
  digitalWrite(motorB2, LOW);
}

void setup() {
  // Ustawienie pinów
  pinMode(motorA1, OUTPUT);
  pinMode(motorA2, OUTPUT);
  pinMode(motorB1, OUTPUT);
  pinMode(motorB2, OUTPUT);
  pinMode(enableA, OUTPUT);
  pinMode(enableB, OUTPUT);
  
  // Włączenie silników
  analogWrite(enableA, 255);
  analogWrite(enableB, 255);

  // Inicjalizacja odbiornika IR
  irrecv.enableIRIn();
}

void loop() {
  if (irrecv.decode()) {
    long irCode = irrecv.decodedIRData.decodedRawData;
    switch (irCode) {
      case IR_FORWARD:
        moveForward();
        break;
      case IR_BACKWARD:
        moveBackward();
        break;
      case IR_LEFT:
        turnLeft();
        break;
      case IR_RIGHT:
        turnRight();
        break;
      case IR_STOP:
        stopMotors();
        break;
    }
    irrecv.resume(); // Przygotowanie do odbioru następnego sygnału
  } 
}

This code is designed to control the robot using an IR remote. The Arduino UNO reads the IR signals and controls the motors via the H-Bridge to move the robot forward, backward, left, right, or stop.