Tinkercad - Controlador L293D

3 min read 1 month ago
Published on Sep 05, 2024 This response is partially generated with the help of AI. It may contain inaccuracies.

Table of Contents

Introduction

This tutorial will guide you through the basic use of the L293D motor driver controller using Tinkercad. The L293D is a popular IC for controlling DC motors due to its ability to drive two motors simultaneously in both forward and reverse directions. By the end of this guide, you will be able to set up a simple simulation to control motors effectively.

Step 1: Setting Up Tinkercad

  • Go to the Tinkercad website and log in or create an account.
  • Start a new project by clicking on “Create New Circuit.”
  • Familiarize yourself with the workspace, including the component library and the circuit editor.

Step 2: Adding Components

  • In the components panel, search for the following items:
    • L293D Motor Driver
    • DC Motors (2 units)
    • Power Supply (Battery or DC source)
    • Arduino Board
    • Connecting Wires
  • Drag and drop these components onto your workspace.

Step 3: Wiring the L293D

  • Connect the L293D as follows:
    • Pin 1 (Enable 1,2) to the Arduino digital pin (for example, pin 9).
    • Pin 2 (Input 1) to another Arduino pin (for example, pin 8).
    • Pin 7 (Input 2) to another Arduino pin (for example, pin 7).
    • Pin 3 (Output 1) to one terminal of the first DC motor.
    • Pin 6 (Output 2) to the other terminal of the first DC motor.
    • Repeat the connections for the second motor using Output 3 and Output 4.
  • Connect the Vcc pin (Pin 8) of the L293D to the positive terminal of the power supply and the ground pin (Pin 4, 5) to the ground.

Step 4: Programming the Arduino

  • Click on the Arduino board and open the code editor.
  • Use the following sample code to control the motors:
#define ENA 9
#define IN1 8
#define IN2 7
#define ENB 10
#define IN3 12
#define IN4 11

void setup() {
  pinMode(ENA, OUTPUT);
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(ENB, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);
}

void loop() {
  // Motor A forward
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  analogWrite(ENA, 255); // Full speed

  // Motor B backward
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
  analogWrite(ENB, 255); // Full speed

  delay(2000); // Run for 2 seconds

  // Stop motors
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, LOW);
  delay(2000); // Stop for 2 seconds
}
  • This code sets the motors to run in opposite directions for two seconds, then stops them.

Step 5: Simulation

  • Click on the “Start Simulation” button in Tinkercad.
  • Observe the motors' behavior based on the code provided.
  • Make adjustments to the code or wiring if the motors do not function as expected.

Conclusion

In this tutorial, you learned how to set up and program the L293D motor driver in Tinkercad. You successfully created a simple simulation to control DC motors. Next steps could include experimenting with different speeds, adding sensors for automation, or integrating additional components to expand your project. Happy tinkering!