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

Arduino UNO-Based Conveyor Control System with Multiple I2C LCD Displays and Pushbutton Inputs

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Conveyor Control System with Multiple I2C LCD Displays and Pushbutton Inputs

Circuit Documentation

Summary

This circuit is designed to control a conveyor system using an Arduino UNO microcontroller. The system includes multiple 16x2 I2C LCD displays, pushbuttons, a DS3231 RTC module, an L298N DC motor driver, and a DC motor. The LCDs display the current date, time, and downtime of the conveyor system. The pushbuttons are used to stop the conveyor, and the RTC module keeps track of the current time.

Component List

  1. 16x2 I2C LCD

    • Description: 16x2 character LCD with I2C interface.
    • Pins: GND, VCC, SDA, SCL
  2. L298N DC Motor Driver

    • Description: Dual H-Bridge motor driver.
    • Pins: OUT1, OUT2, 12V, GND, 5V, OUT3, OUT4, 5V-ENA-JMP-I, 5V-ENA-JMP-O, +5V-J1, +5V-J2, ENA, IN1, IN2, IN3, IN4, ENB
  3. Pushbutton

    • Description: Simple pushbutton switch.
    • Pins: Pin 3 (out), Pin 4 (out), Pin 1 (in), Pin 2 (in)
  4. 9V Battery

    • Description: Standard 9V battery.
    • Pins: -, +
  5. Adafruit DS3231

    • Description: Real-Time Clock (RTC) module.
    • Pins: Vin, GND, SCL, SDA, BAT, 32KHZ, SQW, !RTC_RST
  6. Arduino UNO

    • Description: 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
  7. DC Motor

    • Description: Standard DC motor.
    • Pins: pin 1, pin 2

Wiring Details

16x2 I2C LCD

L298N DC Motor Driver

Pushbutton

9V Battery

Adafruit DS3231

Arduino UNO

DC Motor

Code Documentation

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

// Define constants
#define NUM_POSTS 6
#define CONVEYOR_PIN 13 // pin to control conveyor motor

// Button and LCD pin definitions
const int buttonPins[NUM_POSTS] = {2, 3, 4, 5, 6};
LiquidCrystal_I2C lcds[NUM_POSTS] = {
    LiquidCrystal_I2C(0x27, 16, 2),
    LiquidCrystal_I2C(0x26, 16, 2),
    LiquidCrystal_I2C(0x25, 16, 2),
    LiquidCrystal_I2C(0x24, 16, 2),
    LiquidCrystal_I2C(0x23, 16, 2),
    LiquidCrystal_I2C(0x22, 16, 2),
};

// Variables
RTC_DS3231 rtc;
bool conveyorStopped = false;
unsigned long lastMoveTime = 0;
unsigned long downtimeStart[NUM_POSTS] = {0};
unsigned long totalDowntime[NUM_POSTS] = {0};
bool buttonPressed[NUM_POSTS] = {false};

void setup() {
    // Initialize serial monitor
    Serial.begin(9600);

    // Initialize conveyor control pin
    pinMode(CONVEYOR_PIN, OUTPUT);
    digitalWrite(CONVEYOR_PIN, LOW); // start with conveyor off

    // Initialize buttons
    for (int i = 0; i < NUM_POSTS; i++) {
        pinMode(buttonPins[i], INPUT_PULLUP); // Pull-up configuration
    }

    // Initialize LCDs
    for (int i = 0; i < NUM_POSTS; i++) {
        lcds[i].init();
        lcds[i].backlight();
        lcds[i].setCursor(0, 0);
        lcds[i].print("Initializing....");
    }

    // Initialize RTC
    if (!rtc.begin()) {
        Serial.println("RTC not found!");
        while (1);
    }
}

void loop() {
    // Update date and time
    DateTime now = rtc.now();

    // Check buttons and calculate downtime
    conveyorStopped = false;
    for (int i = 0; i < NUM_POSTS; i++) {
        bool isPressed = !digitalRead(buttonPins[i]); // Active low
        if (isPressed) {
            if (!buttonPressed[i]) {
                // Button just pressed
                downtimeStart[i] = millis();
            }
            buttonPressed[i] = true;
            conveyorStopped = true;
        } else if (buttonPressed[i]) {
            // Button just released
            buttonPressed[i] = false;
            totalDowntime[i] += millis() - downtimeStart[i];
        }
    }

    // Control conveyor
    if (conveyorStopped) {
        digitalWrite(CONVEYOR_PIN, LOW); // Stop conveyor
    } else if (millis() - lastMoveTime >= 120000) { // 2 minutes interval
        digitalWrite(CONVEYOR_PIN, HIGH); // Move conveyor
        delay(2000); // Allow conveyor to move briefly
        digitalWrite(CONVEYOR_PIN, LOW);
        lastMoveTime = millis();
    }

    // Update LCDs
    for (int i = 0; i < NUM_POSTS; i++) {
        lcds[i].clear();
        lcds[i].setCursor(0, 0);
        lcds[i].print("Date:");
        lcds[i].print(now.day(), DEC);
        lcds[i].print("/");
        lcds[i].print(now.month(), DEC);
        lcds[i].print(now.year(), DEC);

        lcds[i].setCursor(0, 1);
        lcds[i].print("Time:");
        lcds[i].print(now.hour(), DEC);
        lcds[i].print(":");
        lcds[i].print(now.minute(), DEC);
        lcds[i].print(" DT:");
        lcds[i].print(totalDowntime[i] / 1000); // Display downtime in seconds
    }
    delay(100); // small delay for stability
}

This code initializes the necessary components, checks the status of the pushbuttons, controls the conveyor motor, and updates the LCD displays with the current date, time, and downtime.