From b06022623775de9ab47ef1ce355c5ecd134b8529 Mon Sep 17 00:00:00 2001
From: guowenxue <guowenxue@gmail.com>
Date: Wed, 30 Jan 2019 11:47:22 +0800
Subject: [PATCH] update LED definition and add infrared source code
---
modules/c/led.c | 4 ++--
modules/c/infrared.c | 35 +++++++++++++++++++++++++++++++++++
modules/c/led.h | 6 +++---
3 files changed, 40 insertions(+), 5 deletions(-)
diff --git a/modules/c/infrared.c b/modules/c/infrared.c
new file mode 100644
index 0000000..6475fc3
--- /dev/null
+++ b/modules/c/infrared.c
@@ -0,0 +1,35 @@
+/*********************************************************************************
+ * 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 <guowenxue@gmail.com>
+ * ChangeLog: 1, Release initial version on "30/01/19 03:37:16"
+ *
+ ********************************************************************************/
+
+#include <stdio.h>
+#include <unistd.h>
+#include <wiringPi.h>
+
+/* 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;
+}
+
diff --git a/modules/c/led.c b/modules/c/led.c
index 514dd85..959edd8 100644
--- a/modules/c/led.c
+++ b/modules/c/led.c
@@ -8,9 +8,9 @@
* pi@raspberrypi:~ $ gpio readall show BCM and wPi pinmap
*
* LED BCM wPi
- * B ---- GPIO.13 ---- GPIO.23
+ * G ---- GPIO.13 ---- GPIO.23
* R ---- GPIO.19 ---- GPIO.24
- * G ---- GPIO.26 ---- GPIO.25
+ * B ---- GPIO.26 ---- GPIO.25
* I ---- GND ----
*
* Version: 1.0.0(2018/10/14)
diff --git a/modules/c/led.h b/modules/c/led.h
index 8e3b4fa..dfc411c 100644
--- a/modules/c/led.h
+++ b/modules/c/led.h
@@ -8,9 +8,9 @@
* pi@raspberrypi:~ $ gpio readall show BCM and wPi pinmap
*
* LED BCM wPi
- * B ---- GPIO.13 ---- GPIO.23
+ * G ---- GPIO.13 ---- GPIO.23
* R ---- GPIO.19 ---- GPIO.24
- * G ---- GPIO.26 ---- GPIO.25
+ * B ---- GPIO.26 ---- GPIO.25
* I ---- GND ----
*
* Version: 1.0.0(2018/10/14)
@@ -37,7 +37,7 @@
/* 3 LEDs WiringPi GPIO port */
/* LED_R LED_G LED_B */
-static int led_gpio[LED_MAX]= { 24, 25, 23 };
+static int led_gpio[LED_MAX]= { 24, 23, 25 };
void init_led(void);
--
Gitblit v1.9.1