Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino-Based Lung Cancer Detector with MQ-2, Sound Sensor, and DHT11

View and Edit Project In Cirkit DesignerImage of Arduino-Based Lung Cancer Detector with MQ-2, Sound Sensor, and DHT11

Lung Cancer Detector Circuit Documentation

Summary

This document provides a detailed overview of the Lung Cancer Detector circuit. The circuit interfaces with various sensors to detect lung cancer indicators and displays the results on a 16x2 LCD. The components used include an Arduino UNO, MQ-2 Gas Sensor, Sound Sensor, DHT11 Temperature and Humidity Sensor, 16x2 LCD Display, Buzzer, Red LED, and a Rotary Potentiometer.

Component List

  1. Arduino UNO

    • Description: 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
  2. MQ-2 Gas Sensor

    • Description: Gas sensor for detecting LPG, i-butane, propane, methane, alcohol, hydrogen, and smoke.
    • Pins: GND, VCC, ANALOG, Digital
  3. Sound Sensor

    • Description: Sensor to detect sound levels.
    • Pins: VCC, GND, DO, AO
  4. DHT11 Temperature and Humidity Sensor

    • Description: Sensor for measuring temperature and humidity.
    • Pins: DATA, GND, VCC
  5. 16x2 LCD Display

    • Description: Alphanumeric display module.
    • Pins: VSS, VDD, V0, RS, RW, E, D1, D0, D2, D3, D4, D6, D5, D7, A, K
  6. Buzzer

    • Description: Audio signaling device.
    • Pins: PIN, GND
  7. LED: Two Pin (Red)

    • Description: Light-emitting diode.
    • Pins: cathode, anode
  8. Rotary Potentiometer

    • Description: Variable resistor.
    • Pins: GND, OUT, VCC
  9. Resistor

    • Description: Fixed resistor.
    • Pins: pin1, pin2
    • Properties: Resistance: 200 Ohms

Wiring Details

Arduino UNO

MQ-2 Gas Sensor

Sound Sensor

DHT11 Temperature and Humidity Sensor

16x2 LCD Display

Buzzer

LED: Two Pin (Red)

Rotary Potentiometer

Resistor

Code Documentation

/*
 * Lung Cancer Detector
 * This Arduino sketch interfaces with various sensors to detect lung cancer.
 * Components:
 * - MQ-2 Gas Sensor
 * - Sound Sensor
 * - DHT11 Temperature and Humidity Sensor
 * - 16x2 LCD Display
 * - Buzzer
 * - LED (Red)
 */

#include <LiquidCrystal.h>
#include <DHT.h>

// Pin definitions
const int mq2Pin = A0; // MQ-2 analog pin
const int soundSensorPin = 2; // Sound sensor digital pin
const int dhtPin = 3; // DHT11 data pin
const int buzzerPin = 4; // Buzzer pin
const int ledPin = 5; // LED pin

// Initialize the LCD library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// Initialize DHT sensor
#define DHTTYPE DHT11
DHT dht(dhtPin, DHTTYPE);

void setup() {
  // Initialize serial communication
  Serial.begin(9600);
  
  // Initialize the LCD
  lcd.begin(16, 2);
  lcd.print("Lung Cancer Det.");
  
  // Initialize the DHT sensor
  dht.begin();
  
  // Set pin modes
  pinMode(mq2Pin, INPUT);
  pinMode(soundSensorPin, INPUT);
  pinMode(buzzerPin, OUTPUT);
  pinMode(ledPin, OUTPUT);
}

void loop() {
  // Read MQ-2 sensor value
  int mq2Value = analogRead(mq2Pin);
  Serial.print("MQ-2 Value: ");
  Serial.println(mq2Value);
  
  // Read sound sensor value
  int soundValue = digitalRead(soundSensorPin);
  Serial.print("Sound Value: ");
  Serial.println(soundValue);
  
  // Read DHT11 sensor values
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  Serial.print("Humidity: ");
  Serial.print(h);
  Serial.print(" %\t");
  Serial.print("Temperature: ");
  Serial.print(t);
  Serial.println(" *C");
  
  // Display values on LCD
  lcd.setCursor(0, 1);
  lcd.print("T:");
  lcd.print(t);
  lcd.print("C H:");
  lcd.print(h);
  lcd.print("%");
  
  // Placeholder for lung cancer detection logic
  // Add your detection logic here
  
  // Example: if MQ-2 value exceeds threshold, activate buzzer and LED
  if (mq2Value > 300) { // Example threshold
    digitalWrite(buzzerPin, HIGH);
    digitalWrite(ledPin, HIGH);
  } else {
    digitalWrite(buzzerPin, LOW);
    digitalWrite(ledPin, LOW);
  }
  
  delay(2000); // Wait for 2 seconds before next loop
}

This code initializes the sensors and LCD, reads sensor values, and displays them on the LCD. It also includes a placeholder for lung cancer detection logic, with an example of activating the buzzer and LED if the MQ-2 sensor value exceeds a threshold.