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

Arduino-Controlled Bidirectional DC Motor Circuit with Pushbutton Interface

View and Edit Project In Cirkit DesignerImage of Arduino-Controlled Bidirectional DC Motor Circuit with Pushbutton Interface

Circuit Documentation

Summary

The circuit in question appears to be a motor control circuit that uses an Arduino UNO microcontroller to drive a DC motor in forward or reverse directions based on the state of two pushbuttons. The circuit includes a series of 1N4007 rectifier diodes, PNP and NPN transistors, resistors, and pushbuttons. The diodes are likely used for flyback protection, and the transistors are used to switch the motor on and off. The resistors are used for base current limiting for the transistors and pull-up resistors for the pushbuttons.

Component List

1N4007 Rectifier Diode

DC Motor

PNP Transistor (EBC)

NPN Transistor (EBC)

Pushbutton

Resistor

Arduino UNO

Wiring Details

1N4007 Rectifier Diode

DC Motor

PNP Transistor (EBC)

NPN Transistor (EBC)

Pushbutton

Resistor

Arduino UNO

Documented Code

// Define pins
const int forwardControlPin = 9; // Control pin for forward
const int backwardControlPin = 10; // Control pin for backward
const int forwardButtonPin = 2; // Button for forward
const int backwardButtonPin = 3; // Button for backward

void setup() {
  // Set control pins as outputs
  pinMode(forwardControlPin, OUTPUT);
  pinMode(backwardControlPin, OUTPUT);

  // Set button pins as inputs with pull-up resistors
  pinMode(forwardButtonPin, INPUT_PULLUP);
  pinMode(backwardButtonPin, INPUT_PULLUP);
}

void loop() {
  // Check if the forward button is pressed
  if (digitalRead(forwardButtonPin) == LOW) { // Button pressed (active low)
    moveForward();
  } 
  // Check if the backward button is pressed
  else if (digitalRead(backwardButtonPin) == LOW) { // Button pressed (active low)
    moveBackward();
  } 
  // If no buttons are pressed, stop the motors
  else {
    stopMotors();
  }
}

// Function to move forward
void moveForward() {
  digitalWrite(forwardControlPin, HIGH);  // Activate forward control
  digitalWrite(backwardControlPin, LOW);  // Deactivate backward control
}

// Function to move backward
void moveBackward() {
  digitalWrite(forwardControlPin, LOW);   // Deactivate forward control
  digitalWrite(backwardControlPin, HIGH); // Activate backward control
}

// Function to stop the motor
void stopMotors() {
  digitalWrite(forwardControlPin, LOW);
  digitalWrite(backwardControlPin, LOW);
}

This code is designed to control the DC motor's direction using the Arduino UNO. The forwardButtonPin and backwardButtonPin are connected to pushbuttons that, when pressed, trigger the motor to move in the corresponding direction. The forwardControlPin and backwardControlPin are likely connected to the base of transistors that control the motor's direction. The code uses internal pull-up resistors for the button inputs and controls the motor direction with simple digital writes to the control pins.