Arduino Mega 2560 Paper Shredding Machine with Bluetooth Control
View and Edit Project In Cirkit Designer
Paper Shredding Machine Circuit Documentation
Summary
This document details the design and implementation of a paper shredding machine circuit. The circuit uses an Arduino Mega 2560 microcontroller to control various components, including DC motors, an ultrasonic sensor, a Bluetooth module, and an LCD display. The motors are driven by an L298N motor driver. The ultrasonic sensor detects the presence of paper, and when paper is detected, the motors driving the conveyor belt and blades are activated.
Component List
Arduino Mega 2560
- Description: Microcontroller board based on the ATmega2560.
- Pins: IOREF, RESET, 3V3, 5V, GND, VIN, A0-A15, D0-D53, AREF, SDA, SCL
DC Motor
- Description: Standard DC motor.
- Pins: pin 1, pin 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
HC-SR04 Ultrasonic Sensor
- Description: Ultrasonic distance sensor.
- Pins: VCC, TRIG, ECHO, GND
Bluetooth HC-06
- Description: Bluetooth module for wireless communication.
- Pins: VCC, GND, TXD, RXD
LCD Display (16 pin)
- Description: 16x2 character LCD display.
- Pins: VSS, VDD, VO, RS, R_W, E, DB0-DB7, A, K
LCM1602 IIC
- Description: I2C interface for LCD display.
- Pins: GND, VCC, SDA, SCL, D0-D7, RS, RW, E, VSS, VDD, V0, A, K
Wiring Details
Arduino Mega 2560
- 5V connected to 5V of L298N DC motor driver, Bluetooth HC-06, and HC-SR04 Ultrasonic Sensor.
- GND connected to GND of L298N DC motor driver, Bluetooth HC-06, HC-SR04 Ultrasonic Sensor, and LCM1602 IIC.
- VIN connected to 12V of L298N DC motor driver.
- D21/SCL connected to SCL of LCM1602 IIC.
- D20/SDA connected to SDA of LCM1602 IIC.
- D19/RX1 connected to RXD of Bluetooth HC-06.
- D18/TX1 connected to TXD of Bluetooth HC-06.
- D2 PWM connected to ENA of L298N DC motor driver.
- D3 PWM connected to ENB of L298N DC motor driver.
- D4 PWM connected to IN1 of L298N DC motor driver.
- D5 PWM connected to IN2 of L298N DC motor driver.
- D6 PWM connected to IN3 of L298N DC motor driver.
- D7 PWM connected to IN4 of L298N DC motor driver.
- D8 PWM connected to ECHO of HC-SR04 Ultrasonic Sensor.
- D9 PWM connected to TRIG of HC-SR04 Ultrasonic Sensor.
DC Motor 1
- pin 1 connected to OUT2 of L298N DC motor driver.
- pin 2 connected to OUT1 of L298N DC motor driver.
DC Motor 2
- pin 1 connected to OUT4 of L298N DC motor driver.
- pin 2 connected to OUT3 of L298N DC motor driver.
L298N DC Motor Driver
- 5V connected to 5V of Arduino Mega 2560.
- GND connected to GND of Arduino Mega 2560.
- 12V connected to VIN of Arduino Mega 2560.
- ENA connected to D2 PWM of Arduino Mega 2560.
- ENB connected to D3 PWM of Arduino Mega 2560.
- IN1 connected to D4 PWM of Arduino Mega 2560.
- IN2 connected to D5 PWM of Arduino Mega 2560.
- IN3 connected to D6 PWM of Arduino Mega 2560.
- IN4 connected to D7 PWM of Arduino Mega 2560.
- OUT1 connected to pin 2 of DC Motor 1.
- OUT2 connected to pin 1 of DC Motor 1.
- OUT3 connected to pin 2 of DC Motor 2.
- OUT4 connected to pin 1 of DC Motor 2.
HC-SR04 Ultrasonic Sensor
- VCC connected to 5V of Arduino Mega 2560.
- GND connected to GND of Arduino Mega 2560.
- TRIG connected to D9 PWM of Arduino Mega 2560.
- ECHO connected to D8 PWM of Arduino Mega 2560.
Bluetooth HC-06
- VCC connected to 5V of Arduino Mega 2560.
- GND connected to GND of Arduino Mega 2560.
- TXD connected to D18/TX1 of Arduino Mega 2560.
- RXD connected to D19/RX1 of Arduino Mega 2560.
LCD Display (16 pin)
- VSS connected to VSS of LCM1602 IIC.
- VDD connected to VDD of LCM1602 IIC.
- VO connected to V0 of LCM1602 IIC.
- RS connected to RS of LCM1602 IIC.
- R_W connected to RW of LCM1602 IIC.
- E connected to E of LCM1602 IIC.
- DB0 connected to D0 of LCM1602 IIC.
- DB1 connected to D1 of LCM1602 IIC.
- DB2 connected to D2 of LCM1602 IIC.
- DB3 connected to D3 of LCM1602 IIC.
- DB4 connected to D4 of LCM1602 IIC.
- DB5 connected to D5 of LCM1602 IIC.
- DB6 connected to D6 of LCM1602 IIC.
- DB7 connected to D7 of LCM1602 IIC.
- A connected to A of LCM1602 IIC.
- K connected to K of LCM1602 IIC.
LCM1602 IIC
- GND connected to GND of Arduino Mega 2560.
- VCC connected to 5V of Arduino Mega 2560.
- SDA connected to D20/SDA of Arduino Mega 2560.
- SCL connected to D21/SCL of Arduino Mega 2560.
Code Documentation
/*
* Paper Shredding Machine
* This code controls a paper shredding machine. An ultrasonic sensor detects
* the presence of paper. When paper is detected, the conveyor belt and the
* blades, both driven by DC motors through an L298N motor driver, are activated.
*/
// Pin definitions
const int trigPin = 9;
const int echoPin = 8;
const int motorEnableA = 2;
const int motorInput1A = 4;
const int motorInput2A = 5;
const int motorEnableB = 3;
const int motorInput3B = 6;
const int motorInput4B = 7;
// Motor speed
const int motorSpeed = 255;
void setup() {
// Initialize serial communication
Serial.begin(9600);
// Initialize ultrasonic sensor pins
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
// Initialize motor driver pins
pinMode(motorEnableA, OUTPUT);
pinMode(motorInput1A, OUTPUT);
pinMode(motorInput2A, OUTPUT);
pinMode(motorEnableB, OUTPUT);
pinMode(motorInput3B, OUTPUT);
pinMode(motorInput4B, OUTPUT);
// Set initial motor states to off
digitalWrite