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

Arduino-Controlled Pressure-Sensitive Automated Motor System

View and Edit Project In Cirkit DesignerImage of Arduino-Controlled Pressure-Sensitive Automated Motor System

Circuit Documentation

Summary

This circuit is designed to control multiple DC motors using L293D motor drivers, with input signals coming from an Arduino Mega 2560 microcontroller. The circuit also includes force sensing resistors (FSRs) to detect pressure and LEDs to indicate the status of different sections of the circuit. Power is supplied by a dedicated power supply unit, and various capacitors and resistors are used for filtering and current limiting purposes.

Component List

Microcontrollers

Motors

Motor Drivers

Sensors

Power Supply

LEDs

Capacitors

Resistors

Wiring Details

DC Motors

L293D Motor Drivers

Force Sensing Resistors (FSRs)

Power Supply

LEDs

Capacitors

Resistors

Documented Code

// Pressure sensor pins
int pressureSensor1 = A0; // Back sensor for column 1
int pressureSensor2 = A1; // Front sensor for column 1
int pressureSensor3 = A2; // Back sensor for column 2
int pressureSensor4 = A3; // Front sensor for column 2
int pressureSensor5 = A4; // Back sensor for column 3
int pressureSensor6 = A5; // Front sensor for column 3

// LED pins for each column
const int redLED1 = 2;  // Red LED for column 1
const int greenLED1 = 3; // Green LED for column 1
const int redLED2 = 4;  // Red LED for column 2
const int greenLED2 = 5; // Green LED for column 2
const int redLED3 = 6;  // Red LED for column 3
const int greenLED3 = 7; // Green LED for column 3

// Motor control pins (L293D)
int motor1Input1 = 23;   
int motor1Input2 = 25;   
int motor2Input1 = 27;   
int motor2Input2 = 29;  
int motor3Input1 = 35;  
int motor3Input2 = 37;  
int motor4Input1 = 39;  
int motor4Input2 = 41;  
int motor5Input1 = 45;  
int motor5Input2 = 47;  
int motor6Input1 = 51;  
int motor6Input2 = 53;  

// Enable pins (optional)
int motor1Enable = 5;   
int motor2Enable = 4;   
int motor3Enable = 6;   
int motor4Enable = 7;   
int motor5Enable = 8;   
int motor6Enable = 9;  

// Threshold for detecting if the pressure sensor is "full" or "empty"
const int threshold = 25;  // Adjust this value based on your sensor's readings

//-------------------------------------------------------------
// Function prototypes
void rotateMotor1();
void rotateMotor2();
void rotateMotor3();
void rotateMotor4();
void rotateMotor5();
void rotateMotor6();
void stopMotor1();
void stopMotor2();
void stopMotor3();
void stopMotor4();
void stopMotor5();
void stopMotor6();
void stopAllMotors();
bool isPressureDetected(int sensorPin);
//----------------------------------------------------------
void setup() {
  // Start the Serial communication
  Serial.begin(9600);

  // Initialize LED pins as output
  pinMode(redLED1, OUTPUT);
  pinMode(greenLED1, OUTPUT);
  pinMode(redLED2, OUTPUT);
  pinMode(greenLED2, OUTPUT);
  pinMode(redLED3, OUTPUT);
  pinMode(greenLED3, OUTPUT);

  
  // Set all control pins to OUTPUT
  pinMode(motor1Input1, OUTPUT);
  pinMode(motor1Input2, OUTPUT);
  
  pinMode(motor2Input1, OUTPUT);
  pinMode(motor2Input2, OUTPUT);
  
  pinMode(motor3Input1, OUTPUT);
  pinMode(motor3Input2, OUTPUT);
  
  pinMode(motor4Input1, OUTPUT);
  pinMode(motor4Input2, OUTPUT);

  pinMode(motor5Input1, OUTPUT);
  pinMode(motor5Input2, OUTPUT);

  pinMode(motor6Input1, OUTPUT);
  pinMode(motor6Input2, OUTPUT);

  // Enable pins setup (if used)
  pinMode(motor1Enable, OUTPUT);
  pinMode(motor2Enable, OUTPUT);
  pinMode(motor3Enable, OUTPUT);
  pinMode(motor4Enable, OUTPUT);
  pinMode(motor5Enable, OUTPUT);
  pinMode(motor6Enable, OUTPUT);

  // Pressure sensor pins setup
  pinMode(pressureSensor1, INPUT);
  pinMode(pressureSensor2, INPUT);
  pinMode(pressureSensor3, INPUT);
  pinMode(pressureSensor4, INPUT);
  pinMode(pressureSensor5, INPUT);
  pinMode(pressureSensor6, INPUT);

  // Initially stop all motors
  stopAllMotors();
}
//-------------------------------------------------------
void loop() {
  // Read pressure sensor values
  int sensorValue1 = analogRead(pressureSensor1); // Back of column 1
  int sensorValue2 = analogRead(pressureSensor2); // Front of column 1
  int sensorValue3 = analogRead(pressureSensor3); // Back of column 2
  int sensorValue4 = analogRead(pressureSensor4); // Front of column 2
  int sensorValue5 = analogRead(pressureSensor5); // Back of column 3
  int sensorValue6 = analogRead(pressureSensor6); // Front of column 3

  // Column 1: Control LED based on sensors 1 (back) and 2 (front)
  if (sensorValue1 <= threshold && sensorValue2 <= threshold) {
    // Both sensors detect product, light up green LED
    digitalWrite(redLED1, LOW);
    digitalWrite(greenLED1, HIGH);
  } else {
    // One or both sensors detect empty, light up red LED
    digitalWrite(redLED1, HIGH);
    digitalWrite(greenLED1, LOW);
  }

  // Column 2: Control LED based on sensors 3 (back) and 4 (front)
  if (sensorValue3 <= threshold && sensorValue4 <= threshold) {
    digitalWrite(redLED2, LOW);
    digitalWrite(greenLED2, HIGH);
  } else {
    digitalWrite(redLED2, HIGH);
    digitalWrite(greenLED2, LOW);
  }

  // Column 3: Control LED based on sensors 5 (back) and 6 (front)
  if (sensorValue5 <= threshold && sensorValue6 <= threshold) {
    digitalWrite(redLED3, LOW);
    digitalWrite(greenLED3, HIGH);
  } else {
    digitalWrite(redLED3, HIGH);
    digitalWrite(greenLED3, LOW);
  }

  // Optional: Print sensor values for debugging
  Serial.print("Sensor 1: "); Serial.println(sensorValue1);
  Serial.print("Sensor 2: "); Serial.println(sensorValue2);
  Serial.print("Sensor 3: "); Serial.println(sensorValue3);
  Serial.print("Sensor 4: "); Serial.println(sensorValue4);
  Serial.print("Sensor 5: "); Serial.println(sensorValue5);
  Serial.print("Sensor 6: "); Serial.println(sensorValue6);

  // Check and output pressure values for each sensor
  int pressure1 = analogRead(pressureSensor1);
  int pressure2 = analogRead(pressureSensor2);
  int pressure3 = analogRead(pressureSensor3);
  int pressure4 = analogRead(pressureSensor4);
  int pressure5 = analogRead(pressureSensor5);
  int pressure6 = analogRead(pressureSensor6);

  // Check pressure for each motor/sensor pair and control motors accordingly
  if (!isPressureDetected(pressureSensor1)) {
    stop