



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
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
1 / 5
This page cannot be seen from the preview
Don't miss anything!




Note; led pin 1 = d Buzz pin = d Led pin 2 = d
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); } }
#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); }