Arduino UNO-Based Conveyor Control System with Multiple I2C LCD Displays and Emergency Stop
View and Edit Project In Cirkit Designer
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, an RTC DS3231 module for real-time clock functionality, an H-bridge motor driver to control a DC motor, and several emergency stop buttons. The Arduino UNO is programmed to manage the conveyor's operation, display real-time data on the LCDs, and handle emergency stop conditions.
Component List
16x2 I2C LCD
- Description: A 16x2 character LCD display with I2C interface.
- Pins: GND, VCC, SDA, SCL
Arduino UNO
- Description: A 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
Emergency STOP
- Description: A normally closed (NC) emergency stop button.
- Pins: NC
RTC DS3231
- Description: A real-time clock module with I2C interface.
- Pins: 32K, SQW, SCL, SDA, VCC, GND
H-Bridge Motor Driver (Ponte H)
- Description: A motor driver module for controlling DC motors.
- Pins: OUT4-Motor2, OUT3-Motor2, OUT2-Motor1, OUT1-Motor1, 5V, GND, 12V, IN3, IN1, IN2, IN4
DC Motor
- Description: A DC motor with two connection pins.
- Pins: pin 1, pin 2
12V 7Ah Battery
- Description: A 12V lead-acid battery.
- Pins: 12v +, 12v -
Wiring Details
16x2 I2C LCD
- GND: Connected to GND of Arduino UNO and RTC DS3231.
- VCC: Connected to 5V of Arduino UNO and VCC of RTC DS3231.
- SDA: Connected to A4 of Arduino UNO and SDA of RTC DS3231.
- SCL: Connected to A5 of Arduino UNO and SCL of RTC DS3231.
Arduino UNO
- GND: Connected to GND of all 16x2 I2C LCDs and RTC DS3231.
- 5V: Connected to VCC of all 16x2 I2C LCDs and RTC DS3231.
- A4 (SDA): Connected to SDA of all 16x2 I2C LCDs and RTC DS3231.
- A5 (SCL): Connected to SCL of all 16x2 I2C LCDs and RTC DS3231.
- D13: Connected to IN1 of H-Bridge Motor Driver.
- D7: Connected to NC of an Emergency STOP button.
- D6: Connected to NC of an Emergency STOP button.
- D5: Connected to NC of an Emergency STOP button.
- D4: Connected to NC of an Emergency STOP button.
- D3: Connected to NC of an Emergency STOP button.
- D2: Connected to NC of an Emergency STOP button.
Emergency STOP
- NC: Connected to GND of Arduino UNO and various digital pins (D2, D3, D4, D5, D6, D7) of Arduino UNO.
RTC DS3231
- GND: Connected to GND of Arduino UNO and all 16x2 I2C LCDs.
- VCC: Connected to 5V of Arduino UNO and all 16x2 I2C LCDs.
- SDA: Connected to A4 of Arduino UNO and SDA of all 16x2 I2C LCDs.
- SCL: Connected to A5 of Arduino UNO and SCL of all 16x2 I2C LCDs.
H-Bridge Motor Driver (Ponte H)
- IN1: Connected to D13 of Arduino UNO.
- OUT1-Motor1: Connected to pin 1 of DC Motor.
- OUT2-Motor1: Connected to pin 2 of DC Motor.
- GND: Connected to 12v - of 12V 7Ah Battery.
- 12V: Connected to 12v + of 12V 7Ah Battery.
DC Motor
- pin 1: Connected to OUT1-Motor1 of H-Bridge Motor Driver.
- pin 2: Connected to OUT2-Motor1 of H-Bridge Motor Driver.
12V 7Ah Battery
- 12v +: Connected to 12V of H-Bridge Motor Driver.
- 12v -: Connected to GND of H-Bridge Motor Driver.
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
#define DEBOUNCE_DELAY 50 // Debounce delay in milliseconds
// Button and LCD pin definitions
const int buttonPins[NUM_POSTS] = {2, 3, 4, 5, 6, 7};
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};
unsigned long lastDebounceTime[NUM_POSTS] = {0};
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 != buttonPressed[i]) {
lastDebounceTime[i] = millis();
}
if ((millis() - lastDebounceTime[i]) > DEBOUNCE_DELAY) {
if (isPressed != buttonPressed[i]) {
buttonPressed[i] = isPressed;
if (isPressed) {
downtimeStart[i] = millis();
} else {
totalDowntime[i] += millis() - downtimeStart[i];
}
}
}
if (buttonPressed[i]) {
conveyorStopped = true;
}
}
// 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("/");