Ardumotive Arduino Greek Playground
  • Home
    • About us
    • Contact
    • License
  • Arduino
    • Tutorials
    • Workshop
  • Raspberry Pi
  • DIY 3D Printer
  • News
    • Events >
      • Unboxing & Review
    • Blog
The 1st Arduino Playground in Greece - Open Source Hardware

PIR Motion Sensor

Available Languages
Picture
Picture

Εισαγωγή​

Picture
 Σε αυτο το tutorial θα δούμε πως μπορούμε να χρησιμοποιήσουμε τον αισθητήρα κίνησης PIR με το Arduino UNO. Ο αισθητήρας αυτός μπορεί να ανιχνεύσει την κίνηση είτε ενός ανθρώπου είτε του κατοικίδιου σας σε απόσταση μέχρι  
6 μέτρα.
​​
Ας ξεκινήσουμε !


Τα υλικά που θα χρειαστείτε


Για το tutorial αυτό θα χρειαστείτε:
  • Arduino uno
  • PIR motion sensor​
  • Μερικά male to female breadboard καλώδια

Το κύκλωμα

Picture
Οι συνδέσεις είναι αρκετά απλές, ακολουθήστε το παραπάνω σχηματικό.
  • Vcc  pin to Arduino 5V Pin
  • GND   pin to Arduino GND
  • Out pin to Arduino 2 Pin

Ο κώδικας

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
 * PIR sensor tester
 */
 
int inputPin = 2;               // choose the input pin (for PIR sensor)
int pirState = LOW;             // we start, assuming no motion detected
int val = 0;                    // variable for reading the pin status
 
void setup() {
  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
    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 {
    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;
    }
  }
}
Κατεβάστε τον κώδικα απ' εδώ και ανοίξτε το αρχείο με το Arduino IDE.
pir_sensor.zip
File Size: 0 kb
File Type: zip
Download File

Σειριακή οθόνη
Picture

​Συγχαρητήρια! 

Μόλις ολοκληρώσαμε άλλο ένα how to. Εύκολο, δύσκολο?
​

​Πείτε μου πως σας φάνηκε στα σχόλια παρακάτω!

Picture

Search Engine

Picture

Licence 

Picture

Help us to grow up!

Picture


Donate us
About us
License
Cookies policy

Visit the biggest Arduino Shop in Greece!

Picture
find us on dwrean.net
find us on Codebender
find us on Instructables
Developed and designed by Vasilakis Michalis Copyright © 2013 Ardumotive All Rights Reserved
All trademarks referenced herein are properties of their
Powered by Create your own unique website with customizable templates.
Design by DivTag Templates