#include <SPI.h> // C++ code // int ledPin = 11; int inputPin = 2; int pirState = LOW; int val = 0; // choose the pin for the LED // choose the input pin (for PIR sensor) // we start, assuming no motion detected // variable for reading the pin status void setup() { pinMode(ledPin, OUTPUT); // declare LED as output pinMode(inputPin, INPUT); // declare sensor as input Serial.begin(9600); } void loop(){ val = digitalRead(inputPin); // read input value if (val == HIGH) { // check if the input is HIGH digitalWrite(ledPin, HIGH); // turn LED ON if (pirState == LOW) { // we have just turned on Serial.println("Motion detected!"); // We only want to print on the output change, not state pirState = HIGH; } } else { digitalWrite(ledPin, LOW); // turn LED OFF if (pirState == HIGH){ // we have just turned of Serial.println("Motion ended!"); // We only want to print on the output change, not state pirState = LOW; } } } void setup() { Serial.begin(9600); pinMode(7, OUTPUT); } void loop() { int c = analogRead(A0); Serial.println(c); if(c<900){ digitalWrite(7, LOW); }else { digitalWrite(7,HIGH); } } int ledPin = 8; int Sensor = A2; void setup() { pinMode(Sensor, INPUT); pinMode(ledPin, OUTPUT); Serial.begin(9600); } void loop(){ Serial.println("MQ5 Heating Up!"); delay(4000); int gas_value = analogRead(Sensor); Serial.print("Sensor Value:"); Serial.println(gas_value); if (gas_value > 450) { digitalWrite(ledPin, HIGH); } else{ digitalWrite(ledPin, LOW); } } int ledPin = 8; int Sensor = A1; int ledPin1 = 11; int inputPin = 2; int pirState = LOW; int val = 0; void setup() { pinMode(Sensor, INPUT); pinMode(ledPin, OUTPUT); pinMode(7, OUTPUT); pinMode(ledPin1, OUTPUT); pinMode(inputPin, INPUT); Serial.begin(9600); } void loop() { Serial.println("MQ5 Heating Up!"); delay(4000); // allow the MQ5 to warm up int gas_value = analogRead(Sensor); Serial.print("Sensor Value:"); Serial.println(gas_value); if (gas_value > 450) { digitalWrite(ledPin, HIGH); } else{ digitalWrite(ledPin, LOW); } int c = analogRead(A0); Serial.println(c); if(c<500){ digitalWrite(7, LOW); }else { digitalWrite(7,HIGH); } val = digitalRead(inputPin); if (val == HIGH) { digitalWrite(ledPin, HIGH); if (pirState == LOW) { Serial.println("Motion detected!"); pirState = HIGH; } } else { digitalWrite(ledPin1, LOW); // turn LED OFF if (pirState == HIGH){ Serial.println("Motion ended!"); pirState = LOW; } } } GAZ DATCHIK VA PHOTORESISTOR int ledPin = 8; int Sensor = A2; void setup() { Serial.begin(9600); pinMode(7, OUTPUT); pinMode(Sensor, INPUT); pinMode(ledPin, OUTPUT); } void loop(){ int c = analogRead(A0); Serial.println(c); if(c<900){ digitalWrite(7, LOW); }else { digitalWrite(7,HIGH); } Serial.println("MQ5 Heating Up!"); delay(4000); int gas_value = analogRead(Sensor); Serial.print("Sensor Value:"); Serial.println(gas_value); if (gas_value > 450) { digitalWrite(ledPin, HIGH); } else{ digitalWrite(ledPin, LOW); } } //10:08:01.628 -> In hex: 30 89 14 1C //10:08:01.628 -> In dec: 48 137 20 28 #include <SPI.h> #include <MFRC522.h> #define SS_PIN 10 #define RST_PIN 9 MFRC522 mfrc522(SS_PIN, RST_PIN); void setup() { Serial.begin(9600); SPI.begin(); mfrc522.PCD_Init(); Serial.println("Approximate your card to the reader..."); Serial.println(); pinMode (6, OUTPUT); pinMode (7, OUTPUT); digitalWrite(7,LOW); digitalWrite(6, LOW); } void loop() { String content= ""; // Scan for cards if ( ! mfrc522.PICC_IsNewCardPresent()) { return; } // Selects a card if ( ! mfrc522.PICC_ReadCardSerial()) { return; } //show UID on serial monitor Serial.print("UID tag :"); for (byte i = 0; i < mfrc522.uid.size; i++) { Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "); Serial.print(mfrc522.uid.uidByte[i], HEX); content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ")); content.concat(String(mfrc522.uid.uidByte[i], HEX)); } Serial.println(); Serial.print("Message : "); content.toUpperCase(); if ((content.substring(1) == "30 89 14 1C") ) //change the codes with the cards codes found after scanning in serial monitor { Serial.println("Authorized access"); Serial.println(); digitalWrite (7,HIGH); delay(3000); digitalWrite (7,LOW); delay(3000); } else { Serial.println(" Access denied"); digitalWrite (6,HIGH); delay(3000); digitalWrite (6, LOW); delay(3000); } } https://www.deviceplus.com/arduino/diy-home-security-make-a-laser-tripwireusing-arduino/ const int photo = 7; const int LED = 9; void setup() { //Pin Configurations //Outputs pinMode(LED, OUTPUT); digitalWrite(LED, LOW); //Inputs pinMode(photo, INPUT_PULLUP); } void loop() { //if/else loop checks if photoresistor is high or low if(digitalRead(photo)==HIGH){ digitalWrite(LED, HIGH); }else{ digitalWrite(LED, LOW); } } const int TRIG_PIN = 6; // Arduino pin connected to Ultrasonic Sensor's TRIG pin const int ECHO_PIN = 7; // Arduino pin connected to Ultrasonic Sensor's ECHO pin const int LED_PIN = 3; // Arduino pin connected to LED's pin const int DISTANCE_THRESHOLD = 50; // centimeters // variables will change: float duration_us, distance_cm; void setup() { Serial.begin (9600); // initialize serial port pinMode(TRIG_PIN, OUTPUT); // set arduino pin to output mode pinMode(ECHO_PIN, INPUT); // set arduino pin to input mode pinMode(LED_PIN, OUTPUT); // set arduino pin to output mode } void loop() { // generate 10-microsecond pulse to TRIG pin digitalWrite(TRIG_PIN, HIGH); delayMicroseconds(10); digitalWrite(TRIG_PIN, LOW); // measure duration of pulse from ECHO pin duration_us = pulseIn(ECHO_PIN, HIGH); // calculate the distance distance_cm = 0.017 * duration_us; if(distance_cm < DISTANCE_THRESHOLD) digitalWrite(LED_PIN, HIGH); // turn on LED else digitalWrite(LED_PIN, LOW); // turn off LED // print the value to Serial Monitor Serial.print("distance: "); Serial.print(distance_cm); Serial.println(" cm"); delay(500); }