

This circuit is designed to interface an Arduino UNO with various sensors, actuators, and an OLED display. The primary components include an Arduino UNO microcontroller, an L298N DC motor driver, two DC motors, a buzzer, two white LEDs, a flame sensor, a DHT11 temperature and humidity sensor, an OLED display, two IR sensors, and a 12V battery. The circuit is capable of reading sensor data, displaying information on the OLED, controlling the buzzer and LEDs based on sensor inputs, and driving the motors.
A4 connected to OLED SCLA5 connected to OLED SDAD12 connected to IR Sensor 2 OUTD11 connected to IR Sensor 1 OUTD10 connected to DHT11 DATAD9 connected to Flame Sensor D0D8 connected to Buzzer PIND7 connected to LED 1 AnodeD6 connected to LED 2 AnodeD5 connected to L298N IN4D4 connected to L298N IN3D3 connected to L298N IN2D2 connected to L298N IN1IN1 to IN4 connected to corresponding Arduino UNO pinsOUT1 and OUT2 connected to DC Motor 1OUT3 and OUT4 connected to DC Motor 212V connected to Battery 12V +GND connected to common ground5V connected to common 5Vpin 1 connected to L298N OUT1pin 2 connected to L298N OUT2pin 1 connected to L298N OUT4pin 2 connected to L298N OUT3PIN connected to Arduino UNO D8GND connected to common groundanode connected to Arduino UNO D7cathode connected to common groundanode connected to Arduino UNO D6cathode connected to common groundVCC connected to common 5VGND connected to common groundD0 connected to Arduino UNO D9DATA connected to Arduino UNO D10GND connected to common groundVCC connected to common 5VGND connected to common groundVCC connected to common 5VSCL connected to Arduino UNO A4SDA connected to Arduino UNO A5+ connected to L298N 12V- connected to common groundout connected to Arduino UNO D11gnd connected to common groundvcc connected to common 5Vout connected to Arduino UNO D12gnd connected to common groundvcc connected to common 5V#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);
}
This code initializes the components and reads data from the sensors. It displays the sensor data on the OLED screen, controls the buzzer based on the flame sensor, and controls the LEDs based on the IR sensors. The motors are set to move forward as an example. You can modify the motor control logic as needed for your application.
To upload the code to your Arduino UNO, follow these steps:
Install the Arduino IDE: