guowenxue
2019-01-30 b06022623775de9ab47ef1ce355c5ecd134b8529
update LED definition and add infrared source code
2 files modified
1 files added
45 ■■■■ changed files
modules/c/infrared.c 35 ●●●●● patch | view | raw | blame | history
modules/c/led.c 4 ●●●● patch | view | raw | blame | history
modules/c/led.h 6 ●●●● patch | view | raw | blame | history
modules/c/infrared.c
New file
@@ -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;
}
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)
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);