/********************************************************************************* * Copyright: (C) 2019 LingYun IoT System Studio * All rights reserved. * * Filename: infrared.c * Description: This file * * Version: 1.0.0(30/01/19) * Author: Guo Wenxue * ChangeLog: 1, Release initial version on "30/01/19 03:37:16" * ********************************************************************************/ #include #include #include /* I/O Pin connected to PIN#16, BCM code pin number is 23 and wPi pin number is 4 */ #define INFRARED_PIN 4 int main (int argc, char **argv) { wiringPiSetup(); pinMode(INFRARED_PIN, INPUT); while(1) { printf("Infrared monitor: %s\n", digitalRead(INFRARED_PIN)? "Someone is closing!":"No one nearby!"); sleep(1); } return 0; }