Circuit Documentation
Summary
This document provides a detailed overview of a circuit designed to control multiple motors, sensors, and a Bluetooth module using an Arduino UNO. The circuit includes components such as an L298N DC motor driver, HC-05 Bluetooth module, ultrasonic sensor, IR receiver, micro servo, rocker switch, and several motors with reducers. The Arduino UNO is programmed to handle various functionalities including motor control, sensor data processing, and Bluetooth communication.
Component List
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-05 Bluetooth Module
- Description: Bluetooth module for wireless communication
- Pins: Key, VCC, GND, TXD, RXD, State
Ultrasonic Sensor
- Description: Distance measurement sensor
- Pins: +VCC, Trigger, Echo, GND
Arduino UNO
- Description: Microcontroller board
- 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
IR Receiver
- Description: Infrared receiver for remote control
- Pins: DATA, VCC, GND
Micro Servo 9G
- Description: Small servo motor
- Pins: GND, +5V, PWM
Rocker Switch
- Description: On/Off switch
- Pins: 1, 2
Motor with Reducer
- Description: Motor with gear reduction
- Pins: 3 - 6 VCC, GND
IR Sensor
- Description: Infrared sensor for object detection
- Pins: out, gnd, vcc
7.4V Battery
- Description: Power source
- Pins: +, -
HX1838 Infrared IR Wireless Remote Control
- Description: Remote control for sending IR signals
- Pins: FFA25D (1), FF629D (2), FFE21D (3), FF22DD (4), FF02FD (5), FFC23D (6), FFE01F (7), FFA857 (8), FF906F (9), FF9867 (0), FFB04F (#), FF6897 (*), FF18E7 (↑), FF5AA5 (→), FF10EF (←), FF4AB5 (↓), FF38C7 (OK)
Wiring Details
L298N DC Motor Driver
- GND connected to 7.4V Battery (-)
- OUT1 connected to Motor with Reducer (GND) (two motors)
- OUT2 connected to Motor with Reducer (3 - 6 VCC) (two motors)
- 12V connected to Arduino UNO (Vin) and Rocker Switch (2)
- OUT3 connected to Motor with Reducer (3 - 6 VCC) (two motors)
- OUT4 connected to Motor with Reducer (GND) (two motors)
- ENA connected to Arduino UNO (D10)
- IN1 connected to Arduino UNO (D9)
- IN2 connected to Arduino UNO (D8)
- IN3 connected to Arduino UNO (D7)
- IN4 connected to Arduino UNO (D6)
- ENB connected to Arduino UNO (D5)
HC-05 Bluetooth Module
- VCC connected to IR Receiver (VCC)
- GND connected to IR Receiver (GND)
- TXD connected to Arduino UNO (D2)
- RXD connected to Arduino UNO (D3)
Ultrasonic Sensor
- GND connected to Micro Servo 9G (GND), IR Sensor (gnd) (two sensors), and Arduino UNO (GND)
- +VCC connected to Micro Servo 9G (+5V), IR Sensor (vcc) (two sensors), and Arduino UNO (5V)
- Trigger connected to Arduino UNO (A3)
- Echo connected to Arduino UNO (A2)
Arduino UNO
- Vin connected to L298N DC Motor Driver (12V) and Rocker Switch (2)
- D10 connected to L298N DC Motor Driver (ENA)
- D9 connected to L298N DC Motor Driver (IN1)
- D8 connected to L298N DC Motor Driver (IN2)
- D7 connected to L298N DC Motor Driver (IN3)
- D6 connected to L298N DC Motor Driver (IN4)
- D5 connected to L298N DC Motor Driver (ENB)
- D2 connected to HC-05 Bluetooth Module (TXD)
- D3 connected to HC-05 Bluetooth Module (RXD)
- A1 connected to IR Sensor (out)
- A0 connected to IR Sensor (out)
- A3 connected to Ultrasonic Sensor (Trigger)
- A2 connected to Ultrasonic Sensor (Echo)
- A4 connected to Micro Servo 9G (PWM)
- A5 connected to IR Receiver (DATA)
IR Receiver
- VCC connected to HC-05 Bluetooth Module (VCC)
- GND connected to HC-05 Bluetooth Module (GND)
- DATA connected to Arduino UNO (A5)
Micro Servo 9G
- GND connected to Ultrasonic Sensor (GND)
- +5V connected to Ultrasonic Sensor (+VCC)
- PWM connected to Arduino UNO (A4)
Rocker Switch
- 1 connected to 7.4V Battery (+)
- 2 connected to L298N DC Motor Driver (12V) and Arduino UNO (Vin)
Motor with Reducer
- GND connected to L298N DC Motor Driver (OUT1) (two motors) and L298N DC Motor Driver (OUT4) (two motors)
- 3 - 6 VCC connected to L298N DC Motor Driver (OUT2) (two motors) and L298N DC Motor Driver (OUT3) (two motors)
IR Sensor
- out connected to Arduino UNO (A1) and Arduino UNO (A0)
- gnd connected to Ultrasonic Sensor (GND) and Arduino UNO (GND)
- vcc connected to Ultrasonic Sensor (+VCC) and Arduino UNO (5V)
7.4V Battery
- + connected to Rocker Switch (1)
- - connected to L298N DC Motor Driver (GND)
Documented Code
#include <SoftwareSerial.h>
SoftwareSerial BT_Serial(2, 3);
#include <IRremote.h>
const int RECV_PIN = A5;
IRrecv irrecv(RECV_PIN);
decode_results results;
#define enA 10
#define in1 9
#define in2 8
#define in3 7
#define in4 6
#define enB 5
#define servo A4
#define R_S A0
#define L_S A1
#define echo A2
#define trigger A3
int distance_L, distance_F = 30, distance_R;
long distance;
int set = 20;
int bt_ir_data;
int Speed = 130;
int mode=0;
int IR_data;
void setup(){
pinMode(R_S, INPUT);
pinMode(L_S, INPUT);
pinMode(echo, INPUT );
pinMode(trigger, OUTPUT