The circuit in question is designed to interface an Arduino UNO with a variety of sensors, actuators, and a display. The primary components include an OLED display for output, a DHT11 sensor for temperature and humidity measurements, IR sensors for object detection, a flame sensor for fire detection, LEDs for visual indication, a buzzer for audio alerts, and a L298N motor driver to control two DC motors. The Arduino UNO serves as the central processing unit, running embedded code to interact with the connected components, process sensor data, and control the actuators based on the sensor inputs.
SCL
connected to Arduino UNO A4
SDA
connected to Arduino UNO A5
GND
connected to common groundVCC
connected to 5V power supplyout
of first IR sensor connected to Arduino UNO D12
out
of second IR sensor connected to Arduino UNO D11
gnd
connected to common groundvcc
connected to 5V power supplyDATA
connected to Arduino UNO D10
GND
connected to common groundVCC
connected to 5V power supplyD0
connected to Arduino UNO D9
GND
connected to common groundVCC
connected to 5V power supplyPIN
connected to Arduino UNO D8
GND
connected to common groundanode
of first LED connected to Arduino UNO D7
anode
of second LED connected to Arduino UNO D6
cathode
connected to common groundIN1
connected to Arduino UNO D2
IN2
connected to Arduino UNO D3
IN3
connected to Arduino UNO D4
IN4
connected to Arduino UNO D5
OUT1
connected to first DC Motor pin 1
OUT2
connected to first DC Motor pin 2
OUT3
connected to second DC Motor pin 2
OUT4
connected to second DC Motor pin 1
12V
connected to 12V battery +
GND
connected to common ground5V
connected to 5V power supply+
connected to L298N DC motor driver 12V
-
connected to common ground#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
// OLED display settings
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
// DHT11 settings
#define DHTPIN 10
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
// Flame sensor pin
#define FLAME_SENSOR_PIN 9
// Buzzer pin
#define BUZZER_PIN 8
// LED pins
#define LED1_PIN 7
#define LED2_PIN 6
// L298N motor driver pins
#define IN1_PIN 2
#define IN2_PIN 3
#define IN3_PIN 4
#define IN4_PIN 5
// IR sensor pins
#define IR_SENSOR1_PIN 11
#define IR_SENSOR2_PIN 12
void setup() {
// Initialize serial communication
Serial.begin(9600);
// Initialize OLED display
if (!display.begin(SSD1306_I2C_ADDRESS, OLED_RESET)) {
Serial.println(F("SSD1306 allocation failed"));
for (;;);
}
display.display();
delay(2000);
display.clearDisplay();
// Initialize DHT11 sensor
dht.begin();
// Initialize flame sensor pin
pinMode(FLAME_SENSOR_PIN, INPUT);
// Initialize buzzer pin
pinMode(BUZZER_PIN, OUTPUT);
// Initialize LED pins
pinMode(LED1_PIN, OUTPUT);
pinMode(LED2_PIN, OUTPUT);
// Initialize motor driver pins
pinMode(IN1_PIN, OUTPUT);
pinMode(IN2_PIN, OUTPUT);
pinMode(IN3_PIN, OUTPUT);
pinMode(IN4_PIN, OUTPUT);
// Initialize IR sensor pins
pinMode(IR_SENSOR1_PIN, INPUT);
pinMode(IR_SENSOR2_PIN, INPUT);
}
void loop() {
// Read DHT11 sensor data
float humidity = dht.readHumidity();
float temperature = dht.readTemperature();
// Read flame sensor data
int flameSensorValue = digitalRead(FLAME_SENSOR_PIN);
// Read IR sensor data
int irSensor1Value = digitalRead(IR_SENSOR1_PIN);
int irSensor2Value = digitalRead(IR_SENSOR2_PIN);
// Display data on OLED
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 0);
display.print("Temp: ");
display.print(temperature);
display.print(" C");
display.setCursor(0, 10);
display.print("Humidity: ");
display.print(humidity);
display.print(" %");
display.setCursor(0, 20);
display.print("Flame: ");
display.print(flameSensorValue ? "No" : "Yes");
display.setCursor(0, 30);
display.print("IR1: ");
display.print(irSensor1Value ? "No" : "Yes");
display.setCursor(0, 40);
display.print("IR2: ");
display.print(irSensor2Value ? "No" : "Yes");
display.display();
// Control buzzer based on flame sensor
if (flameSensorValue == LOW) {
digitalWrite(BUZZER_PIN, HIGH);
} else {
digitalWrite(BUZZER_PIN, LOW);
}
// Control LEDs based on IR sensors
digitalWrite(LED1_PIN, irSensor1Value == LOW ? HIGH : LOW);
digitalWrite(LED2_PIN, irSensor2Value == LOW ? HIGH : LOW);
// Control motors (example: forward motion)
digitalWrite(IN1_PIN, HIGH);
digitalWrite(IN2_PIN, LOW);
digitalWrite(IN3_PIN, HIGH);
digitalWrite(IN4_PIN, LOW);
delay(1000);
}
To upload the code to your Arduino UNO, follow these steps:
Install the Arduino IDE:
Connect the Arduino UNO:
Open the Arduino IDE:
Create a New Sketch:
Copy and Paste the Code:
Install Required Libraries:
Select the Board and Port:
Upload the Code: