2016년 5월 19일 목요일

Raspberry Pi - PIR Motion Sensor 테스트

PIR Motion Sensor는 적외선으로 움직임을 감지하는 센서로 일정한 범위 내에 적외선을 방출하는 물체가 움직일 경우 이를 감지하여 출력 신호로 내보낸다. 센서에 대한 자세한 사양은 다음 웹페이지에서 확인할 수 있으며 테스트를 위해서는 wiringPi가 설치되어 있어야 한다.

http://www.dfrobot.com/wiki/index.php/PIR_Motion_Sensor_V1.0_SKU:SEN0171

테스트 회로는 그림과 같이 PIR Motion Sensor에 5V의 입력 전압을 연결하고 움직임이 감지되었을 때 나오는 출력 전압을 GPIO의 1번에 연결하였다.

회로 및 구성

  • Raspberry Pi 2 Model B
  • PIR Motion Sensor (입력 전압: 3.3 ~ 5V, 출력 전압: High 3V, Low 0V)




테스트를 위해 pir.c 코드를 다음과 같이 작성한다.

#include <stdio.h>
#include <wiringPi.h>

#define PIR 1

int main(void)
{
  if(wiringPiSetup() == -1)
    return 1;

  pinMode(PIR, INPUT);

  int input = 0;

  for(;;)
  {
    if(digitalRead(PIR))
      printf("Motion Detected!\n");

    delay(100);
  }

  return 0;
}

코드를 컴파일 하고 실행 시킨다.

pi@raspberrypi ~$ gcc -o pir pir.c -lwiringPi
pi@raspberrypi ~$ sudo ./pir

Related Posts:

  • Olog Mysql Database SchemaThis is a schema for MySQL Olog database. Just copy and make a file such as "olog.sql". following command can load the file. mysql> source olog.sq… Read More
  • Olog Service Module 설치Olog는 REST 기반의 Web Service Module로 가속기 운영 중 발생하는 다양한 Event에 대한 기록 및 검색을 사용자에게 제공해 주는 모듈이다. Olog는 크게 Servie를 제공하는 Server와 Log를 작성하는 Client로 구성되어 있… Read More
  • Debian Jessie에서 Java 설치update-alternatives 명령을 사용하면 새로운 버전의 Java를 추가 및 변경할 수 있다. 우선 현재 사용하고 있는 Java 버전을 확인한다. scwook@debian:~$ java -version openjdk version "1.8.0_72-i… Read More
  • Rasbperry Pi - wiringPi 설치Raspberry Pi에서 GPIO Port를 사용할 수 있는 방법 중 하나는 wiringPi를 이용하는 것이다. wiringPi에 대한 기본적인 사용 방법 및 wiringPi 홈페이지에서 확인할 수 있다. http://wiringpi.com/ wiringPi는 소… Read More
  • Debian에서 Glassfish 설치 Glassfish를 설치하기 전 Java 버전을 먼저 확인한다. Glassfish V3는 JDK 1.7.0, Glassfish V4는 JDK 1.8.0 이상 설치되어 있어야 한다. scwook@debian:~/Download# java -version … Read More

0 개의 댓글:

댓글 쓰기