Arduino Sensor Project: IR, Flame, MQ5 Gas, SIM800L Module, and Ultrasonic Sensor, Schemes and Mind Maps of Law

A collection of arduino projects that demonstrate the use of various sensors, including an ir sensor, flame sensor, mq5 gas sensor, sim800l module for sms functionality, and an ultrasonic sensor. Each project includes a code snippet and brief instructions for setting up the hardware and software components.

Typology: Schemes and Mind Maps

2023/2024

Uploaded on 03/25/2024

steph-marie-2
steph-marie-2 🇵🇭

1 document

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Ir sensor ,code
const int ledpin=13;
const int flamepin=A2;
const int buzpin=11;
const int threshold=200;
int flamesensvalue=0;
void setup() {
Serial.begin(9600);
pinMode(ledpin,OUTPUT);
pinMode(flamepin,INPUT);
pinMode(buzpin,OUTPUT);
}
void loop() {
flamesensvalue=analogRead(flamepin);
if (flamesensvalue<=threshold) {
Serial.println(flamesensvalue);
digitalWrite(ledpin,HIGH);
tone(buzpin,100);
delay(1000);
} else {
digitalWrite(ledpin,LOW);
noTone(buzpin);
}
}
Note;
led pin 1 = d13
Buzz pin = d11
Led pin 2 = d12
pinMode(ledpin2,OUTPUT);
pinMode(ledpin1,OUTPUT);
If flamevalue = 200 ;
pf3
pf4
pf5

Partial preview of the text

Download Arduino Sensor Project: IR, Flame, MQ5 Gas, SIM800L Module, and Ultrasonic Sensor and more Schemes and Mind Maps Law in PDF only on Docsity!

Ir sensor ,code

const int ledpin=13;

const int flamepin=A2;

const int buzpin=11;

const int threshold=200;

int flamesensvalue=0;

void setup() {

Serial.begin(9600);

pinMode(ledpin,OUTPUT);

pinMode(flamepin,INPUT);

pinMode(buzpin,OUTPUT);

void loop() {

flamesensvalue=analogRead(flamepin);

if (flamesensvalue<=threshold) {

Serial.println(flamesensvalue);

digitalWrite(ledpin,HIGH);

tone(buzpin,100);

delay(1000);

} else {

digitalWrite(ledpin,LOW);

noTone(buzpin);

Note; led pin 1 = d Buzz pin = d Led pin 2 = d

pinMode(ledpin 2 ,OUTPUT);

pinMode(ledpin 1 ,OUTPUT);

If flamevalue = 200 ;

Mq5 gas sensor const int LED_PIN = 2; const int BUZZER_PIN = 4; const int ANALOG_PIN = A0; const int GAS_THRESHOLD = 130; void setup() { Serial.begin(9600); pinMode(LED_PIN, OUTPUT); pinMode(BUZZER_PIN, OUTPUT); } void loop() { int gasLevel = analogRead(ANALOG_PIN); Serial.println(gasLevel); // For debugging, can be removed in final version if (gasLevel > GAS_THRESHOLD) { Serial.println("Gas Detection!!"); digitalWrite(LED_PIN, HIGH); digitalWrite(BUZZER_PIN, HIGH); delay(1000); digitalWrite(LED_PIN, LOW); digitalWrite(BUZZER_PIN, LOW); delay(1000); } }

ULTRASONIC

#include <Arduino.h> const int TriggerPin = 8; const int EchoPin = 9; long Duration = 0; int Delay_timer = 1000; void setup() { pinMode(TriggerPin, OUTPUT); pinMode(EchoPin, INPUT); Serial.begin(9600); } long Distance(long time){ long DistanceCalc; DistanceCalc = ((time * 0.034) / 2); // centimeters return DistanceCalc; } void loop() { // put your main code here, to run repeatedly: digitalWrite(TriggerPin, LOW); delayMicroseconds(2); digitalWrite(TriggerPin,HIGH); delayMicroseconds(10); digitalWrite(TriggerPin, LOW); Duration = pulseIn(EchoPin,HIGH); long Distance_cm = Distance(Duration); Serial.print("Distance = "); Serial.print(Distance_cm); Serial.println (" cm"); delay(Delay_timer); }