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

Arduino-Controlled Conveyor Belt and Water Pump System with Piezoelectric Sensors

View and Edit Project In Cirkit DesignerImage of Arduino-Controlled Conveyor Belt and Water Pump System with Piezoelectric Sensors

Circuit Documentation

Summary

The circuit in question appears to be designed for a system that involves motion control and fluid pumping, likely part of a larger automated or semi-automated process. It includes two DC motors controlled by an L298N motor driver, a water pump controlled by a 5V relay, multiple piezo sensors for input, and an Arduino UNO microcontroller for control logic. The circuit also includes power supply components, protective diodes, a transistor for LED control, and resistors for current limiting and pull-down purposes.

Component List

DC Motor

5V Relay

Piezo Sensor

2x 18650 Battery Pack

Water Pump

L298N DC Motor Driver

Arduino UNO

Diode

Electrolytic Capacitor

Resistor

BC547 Transistor

LED (Yellow)

Wiring Details

DC Motor

5V Relay

Piezo Sensor

2x 18650 Battery Pack

Water Pump

L298N DC Motor Driver

Arduino UNO

Diode

Electrolytic Capacitor

Resistor

BC547 Transistor

LED (Yellow)

Documented Code

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// Define the LCD address, for a 16x2 LCD
LiquidCrystal_I2C lcd(0x27, 16, 2);

// Pin assignments for garbage collector
int relayPin = 7;  // Relay connected to digital pin 7 (controls water pump)
int motorIn1 = 2;  // Motor driver IN1 for conveyor belt motor 1
int motorIn2 = 3;  // Motor driver IN2 for conveyor belt motor 1
int motorIn3 = 4;  // Motor driver IN3 for conveyor belt motor 2
int motorIn4 = 5;  // Motor driver IN4 for conveyor belt motor 2
int motorSpeed = 6; // Motor driver ENA (PWM speed control for both motors)

// Pin assignments for piezoelectric sensor and LCD
const int piezoPin = A0;  // Piezoelectric sensor connected to A0
const int g24Pin = 8;     // G24 connected to digital pin 8

void setup() {
  // Initialize LCD
  lcd.begin();
  lcd.backlight();  // Turn on the backlight

  // Initialize Serial for debugging
  Serial.begin(9600);

  // Set pin modes for motors, relay, and piezo sensor
  pinMode(relayPin, OUTPUT);
  pinMode(motorIn1, OUTPUT);
  pinMode(motorIn2, OUTPUT);
  pinMode(motorIn3, OUTPUT);
  pinMode(motorIn4, OUTPUT);
  pinMode(motorSpeed, OUTPUT);
  pinMode(piezoPin, INPUT);
  pinMode(g24Pin, INPUT);  // Assuming G24 is a sensor input

  // Print initial message on LCD
  lcd.setCursor(0, 0);
  lcd.print("Piezo Reading:");

  // Start with motors and pump off
  digitalWrite(relayPin, LOW);
  digitalWrite(motorIn1, LOW);
  digitalWrite(motorIn2, LOW);
  digitalWrite(motorIn3, LOW);
  digitalWrite(motorIn4, LOW);
  analogWrite(motorSpeed, 0);  // Motor speed set to 0
}

void loop() {
  // Read the piezoelectric sensor value
  int piezoValue = analogRead(piezoPin);
  int g24State = digitalRead(g24Pin);

  // Print piezo value to Serial Monitor
  Serial.print("Piezoelectric Value: ");
  Serial.println(piezoValue);

  // Display piezoelectric sensor value on the LCD
  lcd.setCursor(0, 1);
  lcd.print("Value: ");
  lcd.print(piezoValue);
  lcd.print("   ");  // Clear leftover characters

  // If piezo sensor detects sufficient pressure or G24 is HIGH, run motors
  if (piezoValue > 100 || g24State == HIGH) {
    // Run conveyor belt motors forward
    digitalWrite(motorIn1, HIGH);
    digitalWrite(motorIn2, LOW);
    digitalWrite(motorIn3, HIGH);
    digitalWrite(motorIn4, LOW);
    analogWrite(motorSpeed, 255);  // Full speed

    // Turn on the water pump
    digitalWrite(relayPin, HIGH);  // Water pump ON
  } else {
    // Stop everything if no piezoelectric reading or G24 is LOW
    digitalWrite(relayPin, LOW);  // Turn off water pump
    analogWrite(motorSpeed, 0);   // Stop conveyor motors
  }

  delay(500);  // Small delay before next reading
}

This code is designed to run on an Arduino UNO and controls the motors, relay, and reads the piezo sensors. It also includes an LCD display for showing sensor readings. The code is structured with setup and loop functions, typical for Arduino sketches. The setup function initializes the LCD, serial communication, and pin modes, while the loop function reads sensor values, controls the motors and relay, and updates the LCD display.