update LED definition and add infrared source code
2 files modified
1 files added
New file |
| | |
| | | /********************************************************************************* |
| | | * 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; |
| | | } |
| | | |
| | |
| | | * 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) |
| | |
| | | * 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) |
| | |
| | | /* 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); |