?

단축키

Prev이전 문서

Next다음 문서

+ - Up Down Comment Print
?

단축키

Prev이전 문서

Next다음 문서

+ - Up Down Comment Print

참고: http://blog.prettymay.com/220670957502


[설치]

$ sudo apt-get install lirc liblircclient-dev


[핀설정]

$ sudo nano /etc/modules

파일 끝에 아래 내용을 추가

lirc_dev

lirc_rpi gpio_in_pin=18  <-- 연결된 핀번호


$ sudo nano /etc/lirc/hardware.conf

아래내용으로 수정

LIRCD_ARGS="--uinput"

DRIVER="default"

DEVICE="/dev/lirc0"

MODULES="lirc_rpi"


$ sudo nano /boot/config.txt


[수신확인]

$ sudo /etc/init.d/lirc stop

$ mode2 -d /dev/lirc0


[키와 매핑하기 (record)]

$ irrecord -d /dev/lirc0 ~/lircd.conf

그러면 모든 키를 입력라하는 말이 나옴. 그과정에 lircd.conf 파일이 만들어짐


$sudo cp ~/lircd.conf /etc/lirc/lircd.conf

덮어 쓰기.


[데몬 시작]

$ sudo /etc/init.d/lirc restart



테스트 소스


#include <wiringPi.h>
#include <lirc/lirc_client.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#define LED_B	4
#define LED_R	5
#define LED_G	6

#define LED_ON	1
#define LED_OFF	0

void ledOnOff(int led) {
	if (digitalRead(led) == LED_ON)
		digitalWrite(led, LED_OFF);
	else
		digitalWrite(led, LED_ON);
}

int main() {
	struct lirc_config *config;

	int buttonTimer = millis();
	char *code;

	if (wiringPiSetup() == -1) 
		exit(1);

	pinMode(LED_B, OUTPUT);
	pinMode(LED_R, OUTPUT);
	pinMode(LED_G, OUTPUT);

	if (lirc_init("lirc", 1) == -1)
		exit(EXIT_FAILURE);

	if (lirc_readconfig(NULL, &config, NULL) == 0) {
		while (lirc_nextcode(&code) == 0) {
			if (code == NULL)
				continue;

			if (millis() - buttonTimer > 400) {
				if (strstr(code, "KEY_1")) {
					printf("Match on KEY_1\n");
					ledOnOff(LED_B);
					buttonTimer = millis();
				} else if (strstr(code, "KEY_2")) {
					printf("Match on KEY_2\n");
					ledOnOff(LED_R);
					buttonTimer = millis();
				} else if (strstr(code, "KEY_3")) {
					printf("Match on KEY_3\n");
					ledOnOff(LED_G);
					buttonTimer = millis();
				}
			}

			free(code);
		}

		lirc_freeconfig(config);
	}

	lirc_deinit();
	exit(EXIT_SUCCESS);
}






Dreamy의 코드 스크랩

내가 모으고 내가 보는

List of Articles
번호 분류 제목 날짜 조회 수 추천 수
506 Pi 라즈베리파이 웹페이지 자동 실행 설정 방법 secret 2020.11.03 0 0
505 일반 프리미어 프로 Premier Pro secret 2022.02.04 0 0
504 Android CDMA 모델에서의 IMEI secret 2013.04.22 0 0
503 PHP php 기본 문법 정리 secret 2014.01.16 0 0
502 Android Android Framework 분석을 위한 C++ 강의노트 secret 2014.07.25 0 0
501 업무 Force To Crash Guide 강제로 Crash 내기 secret 2014.11.27 0 0
500 업무 SurfaceFlinger dump 하기 secret 2014.12.04 0 0
499 업무 ION memory allocator secret 2014.12.15 0 0
498 업무 Ram Dump Parser 사용법 secret 2014.12.15 0 0
497 업무 CTS 테스트 가이드 secret 2015.01.02 0 0
496 Android Eclipse에서 Android Full Source 확인하는 방법 secret 2015.01.07 0 0
495 업무 Mediaplayer ErrorCode 검색하기(.h파일) secret 2015.01.16 0 0
494 업무 Dump 받은 파티션을 mount해서 보는 방법 secret 2015.02.12 0 0
493 Android Android GDB Debugging secret 2015.03.11 0 0
492 LINUX 내 .bashrc 설정 secret 2015.08.31 0 0
목록
Board Pagination ‹ Prev 1 2 3 4 5 6 7 8 9 10 ... 34 Next ›
/ 34

나눔글꼴 설치 안내


이 PC에는 나눔글꼴이 설치되어 있지 않습니다.

이 사이트를 나눔글꼴로 보기 위해서는
나눔글꼴을 설치해야 합니다.

설치 취소

Designed by sketchbooks.co.kr / sketchbook5 board skin

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5