8. Gas Watchdog
Code
int mq2Pin = A0;
int buzzerPin = 8;
int threshold = 300;
void setup() {
pinMode(buzzerPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
int gasValue = analogRead(mq2Pin);
Serial.print("Gas Level: ");
Serial.println(gasValue);
if (gasValue > threshold) {
tone(buzzerPin, 1000);
delay(200);
noTone(buzzerPin);
delay(200);
}
delay(100);
}
Info
"Gas Watchdog" - MQ2-based gas leak detector that sounds an alarm when hazardous gas levels are detected.
9. Booze Detector
Code
int mq3Pin = A0;
int ledPin = 13;
int threshold = 400;
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
int alcoholValue = analogRead(mq3Pin);
Serial.print("Alcohol Level: ");
Serial.println(alcoholValue);
if (alcoholValue > threshold) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}
delay(1000);
}
Info
"Booze Detector" - MQ3 alcohol sensor that lights an LED when alcohol vapors are present.
10. Air Quality Check
Code
int mq135Pin = A0;
void setup() {
Serial.begin(9600);
}
void loop() {
int airQuality = analogRead(mq135Pin);
Serial.print("Air Quality: ");
Serial.println(airQuality);
if (airQuality > 300) {
Serial.println("Poor Air Quality!");
} else {
Serial.println("Air Quality OK");
}
delay(1000);
}
Info
"Air Quality Check" - MQ135 sensor-based system that monitors air pollution levels and warns of poor air quality.
11. Gas Leak Sentinel
Code
int mq5Pin = A0;
int buzzerPin = 8;
int threshold = 350;
void setup() {
pinMode(buzzerPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
int gasValue = analogRead(mq5Pin);
Serial.print("Gas Level: ");
Serial.println(gasValue);
if (gasValue > threshold) {
tone(buzzerPin, 1000);
delay(1000);
noTone(buzzerPin);
}
delay(500);
}
Info
"Gas Leak Sentinel" - MQ5-based natural gas detector with buzzer alerts for hazardous leaks.
12. Motion Guard
Code
int pirPin = 2;
int ledPin = 13;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(pirPin, INPUT);
Serial.begin(9600);
}
void loop() {
int motion = digitalRead(pirPin);
if (motion == HIGH) {
digitalWrite(ledPin, HIGH);
Serial.println("Motion detected!");
} else {
digitalWrite(ledPin, LOW);
}
delay(100);
}
Info
"Motion Guard" - PIR motion sensor that triggers an LED when movement is detected, useful for security.
13. Plant Hydration Monitor
Code
int soilPin = A0;
void setup() {
Serial.begin(9600);
}
void loop() {
int moisture = analogRead(soilPin);
Serial.print("Soil Moisture: ");
Serial.println(moisture);
if (moisture > 700) {
Serial.println("Soil is too dry!");
} else if (moisture > 400) {
Serial.println("Soil moisture is good");
} else {
Serial.println("Soil is too wet!");
}
delay(1000);
}
Info
"Plant Hydration Monitor" - Soil moisture sensor that checks if plants need watering and alerts when soil is too dry.
14. Rain Alert
Code
int rainPin = A0;
int buzzerPin = 8;
int threshold = 500;
void setup() {
pinMode(buzzerPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
int rainValue = analogRead(rainPin);
Serial.print("Rain Level: ");
Serial.println(rainValue);
if (rainValue < threshold) {
tone(buzzerPin, 1000);
delay(500);
noTone(buzzerPin);
delay(500);
}
delay(100);
}
Info
"Rain Alert" - Rain sensor that detects water and triggers a buzzer, useful for weather monitoring.
15. Motor Commander
Code
int enA = 9;
int in1 = 8;
int in2 = 7;
void setup() {
pinMode(enA, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
}
void loop() {
// Rotate clockwise
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
analogWrite(enA, 200); // Speed control
delay(2000);
// Stop
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
delay(1000);
// Rotate counter-clockwise
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
analogWrite(enA, 200); // Speed control
delay(2000);
// Stop
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
delay(1000);
}
Info
"Motor Commander" - DC motor controller using an L298N driver to change speed and direction.