블로그 이미지
훅크선장

카테고리

분류 전체보기 (361)
사진이야기 (23)
펭귄컴퓨팅 (120)
컴퓨터보안 (84)
절름발이 프로그래머 (59)
하드웨어개조 (23)
멀알려줄까 (35)
홈베이킹&홈쿠킹 (2)
잡다한것들 (15)
Total
Today
Yesterday

달력

« » 2024.4
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30

공지사항

태그목록

최근에 올라온 글

리모콘을 잃어버린 중국제 LED 벽시계의 시간설정을 위해서, 

아두이노 우노와 만능 멤브레인 키패드 3x4, 그리고 IR 송수신 모듈을 가지고  시계용 IR 리모콘을 한번 만들어 보았다.

 

제일 어려운 것이 리모콘의 송신 신호를 알아내는 것이었다. 리모콘이 있다면, 신호를 송신해보고 그 신호를 복제하는 방법으로 하면 쉽게 갈 수 있지만, 리모콘이 없으므로 모든 코드 신호를 다 보내보면서 시계쪽의 변화를 봐야했기에 완전 쌩노가다였다.

 

무아스 퓨어 39cm 슬림형 LED 벽시계
리모콘 키
1) 전원버튼  
0x1C :  LED 전원 On/Off
2) 화면전환, 디스플레이모드 설정(시간, 날짜, 온도)
0x40 :  시간 -> 날짜  -> 온도 
 x1 x1  -> 22 oC
3) 자동밝기 모드 on/off  
0x08 : 자동밝기모드  
L-01 (자동밝기모드 Off)  -> L-AU (자동밝기모드 On)
0x08, sRepeates 20 : 시간구분점 페이드인 아웃 설정정
 Fd --  -> Fd 0n
4) 알람 ON/OFF
0x44 : AL -- (알람 Off)  ->  AL On  (알람 On)
5) 길게 눌러 시간설정  
0x5E, sRepeates 20 : 
6) 알람시간 확인, 길게 눌러 알람시간 설정
0x4A   6:30
7) 수동밝기모드에서 밝기 올림, 설정모드에서 숫자 올림  
0x18 : up
8) 수동밝기모드에서 밝기 내림, 설정모드웨서 숫자 내림
0x52 : down 

 

아두이노 IDE에 keypad 라이브러리와 IRremote 라이브러리를 설치해서 아래 코드를 아두이노 우노에 업로드하면 된다.

물론 키패드와 송수신 모듈을 아두이노와 연결해야 되는데, 연결방법은 인터넷에 다 있다. (검색하면 된다.)

 

참조 사이트:

https://www.makerguides.com/ir-receiver-remote-arduino-tutorial/

 

IR Remote and Receiver with Arduino Tutorial (4 Examples)

Learn how to use an infrared (IR) sensor/receiver and remote with the Arduino. Wiring diagrams and many example codes included!

www.makerguides.com

https://github.com/Arduino-IRremote/Arduino-IRremote#sending-ir-codes

 

GitHub - Arduino-IRremote/Arduino-IRremote: Infrared remote library for Arduino: send and receive infrared signals with multiple

Infrared remote library for Arduino: send and receive infrared signals with multiple protocols - GitHub - Arduino-IRremote/Arduino-IRremote: Infrared remote library for Arduino: send and receive in...

github.com

https://mechatrofice.com/arduino/keypad-interfacing-with-arduino

 

Keypad Interfacing with Arduino 4x4, 4x3 with LCD connection and code

A Matrix Keypad is a very useful module for embedded systems and a variety of projects. This tutorial briefly explains the interface of 4×3 and 4×4 keypads with Arduino and few programs using keypad...

mechatrofice.com

https://lastminuteengineers.com/arduino-keypad-tutorial/

 

In-Depth: Interface 4x3 & 4x4 Membrane Keypad with Arduino

Learn about 4x3 & 4x4 Membrane Keypad along with its Working, Pinout, Wiring, Library, Arduino Code for Reading Key Presses.

lastminuteengineers.com

keypad 라이브러리에는 한번 누름만 존재하고, 길게 누름에 대한 함수가 존재하지 않기 때문에,

그냥 길게 누름의 신호를 별도의 키 하나에 할당해서 간단하게 구현하였다.

LED 벽시계의 키는 8개뿐이지만, 길게 누름이 3개 할당되어 있어서, 키를 11개만 쓰면 되기 때문에.

// Code for IR controller of Mooas LCD Digital Wall Clock
// coded by HooK7346
// 2023. 3. 8.
/*
* Key # : LED On/Off
* Key * : Change Display
* Key 1 : Brightness Auto On/Off
* Key 2 : Time dot Fade In/Out setting
* Key 3 : Alarm On/Off
* Key 4 : Settings Menu
* Key 5 : OK, Next
* Key 7 : Alarm Time Check
* Key 8 : Alarm Setting
* Key 6 : Up
* Key 9 : Down
*/

#include <Arduino.h>
#define DISABLE_CODE_FOR_RECEIVER // Saves 450 bytes program memory and 269 bytes RAM if receiving functions are not used.
//#define SEND_PWM_BY_TIMER // Disable carrier PWM generation in software and use (restricted) hardware PWM.
//#define USE_NO_SEND_PWM // Use no carrier PWM, just simulate an active low receiver signal. Overrides SEND_PWM_BY_TIMER definition
#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc.
#include <IRremote.hpp>
#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
{'1', '2', '3'},
{'4', '5', '6'},
{'7', '8', '9'},
{'*', '0', '#'}
};
byte rowPins[ROWS] = {2, 3, 4, 5};
byte colPins[COLS] = {6, 7, 8};

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

uint8_t sCmd_LED_On_Off = 0x1C;
uint8_t sCmd_Change_Display = 0x40;
uint8_t sCmd_Bright_Auto_On_Off = 0x08;
uint8_t sCmd_Alarm_On_Off = 0x44;
uint8_t sCmd_Setting = 0x5E;
uint8_t sCmd_Alarm_Setting = 0x4A;
uint8_t sCmd_Up = 0x18;
uint8_t sCmd_Down = 0x52;

uint8_t sRepeats_short = 0;
uint8_t sRepeats_long = 30;

void setup() {
pinMode(LED_BUILTIN, OUTPUT);

Serial.begin(115200);
 
IrSender.begin(DISABLE_LED_FEEDBACK); // Start with IR_SEND_PIN as send pin and disable feedback LED at default feedback LED pin

Serial.print(F("Send IR signals at pin "));
Serial.println(IR_SEND_PIN);
}

void loop() {
char key = keypad.getKey();
switch (key) {
case '#':
/*
* Print current send values
*/
//Serial.println();
Serial.print(F("Send now: address=0x00, command=0x"));
Serial.print(sCmd_LED_On_Off, HEX);
Serial.print(F(", repeats="));
Serial.print(sRepeats_short);
Serial.println();

//Serial.println(F("Send standard NEC with 8 bit address"));
Serial.flush();

IrSender.sendNEC(0x00, sCmd_LED_On_Off, sRepeats_short);

break;
case '*': // Change Display button
/*
* Print current send values
*/
//Serial.println();
Serial.print(F("Send now: address=0x00, command=0x"));
Serial.print(sCmd_Change_Display, HEX);
Serial.print(F(", repeats="));
Serial.print(sRepeats_short);
Serial.println();

//Serial.println(F("Send standard NEC with 8 bit address"));
Serial.flush();

IrSender.sendNEC(0x00, sCmd_Change_Display, sRepeats_short);

break;
case '1': // Brightness Auto On/Off button
/*
* Print current send values
*/
//Serial.println();
Serial.print(F("Send now: address=0x00, command=0x"));
Serial.print(sCmd_Bright_Auto_On_Off, HEX);
Serial.print(F(", repeats="));
Serial.print(sRepeats_short);
Serial.println();

//Serial.println(F("Send standard NEC with 8 bit address"));
Serial.flush();

IrSender.sendNEC(0x00, sCmd_Bright_Auto_On_Off, sRepeats_short);

break;
case '2': // Time dot Fade In/Out setting button
/*
* Print current send values
*/
//Serial.println();
Serial.print(F("Send now: address=0x00, command=0x"));
Serial.print(sCmd_Bright_Auto_On_Off, HEX);
Serial.print(F(", repeats="));
Serial.print(sRepeats_long);
Serial.println();

//Serial.println(F("Send standard NEC with 8 bit address"));
Serial.flush();

IrSender.sendNEC(0x00, sCmd_Bright_Auto_On_Off, sRepeats_long);

break;
case '3': // Alarm On/Off button
/*
* Print current send values
*/
//Serial.println();
Serial.print(F("Send now: address=0x00, command=0x"));
Serial.print(sCmd_Alarm_On_Off, HEX);
Serial.print(F(", repeats="));
Serial.print(sRepeats_short);
Serial.println();

//Serial.println(F("Send standard NEC with 8 bit address"));
Serial.flush();

IrSender.sendNEC(0x00, sCmd_Alarm_On_Off, sRepeats_short);

break;
case '4': // Settings Menu button
/*
* Print current send values
*/
//Serial.println();
Serial.print(F("Send now: address=0x00, command=0x"));
Serial.print(sCmd_Setting, HEX);
Serial.print(F(", repeats="));
Serial.print(sRepeats_long);
Serial.println();

//Serial.println(F("Send standard NEC with 8 bit address"));
Serial.flush();

IrSender.sendNEC(0x00, sCmd_Setting, sRepeats_long);

break;
case '5': // OK, Next button
/*
* Print current send values
*/
//Serial.println();
Serial.print(F("Send now: address=0x00, command=0x"));
Serial.print(sCmd_Setting, HEX);
Serial.print(F(", repeats="));
Serial.print(sRepeats_short);
Serial.println();

//Serial.println(F("Send standard NEC with 8 bit address"));
Serial.flush();

IrSender.sendNEC(0x00, sCmd_Setting, sRepeats_short);

break;
case '7': // Alarm Time Check button
/*
* Print current send values
*/
//Serial.println();
Serial.print(F("Send now: address=0x00, command=0x"));
Serial.print(sCmd_Alarm_Setting, HEX);
Serial.print(F(", repeats="));
Serial.print(sRepeats_short);
Serial.println();

//Serial.println(F("Send standard NEC with 8 bit address"));
Serial.flush();

IrSender.sendNEC(0x00, sCmd_Alarm_Setting, sRepeats_short);

break;
case '8': // Alarm Settings button
/*
* Print current send values
*/
//Serial.println();
Serial.print(F("Send now: address=0x00, command=0x"));
Serial.print(sCmd_Alarm_Setting, HEX);
Serial.print(F(", repeats="));
Serial.print(sRepeats_long);
Serial.println();

//Serial.println(F("Send standard NEC with 8 bit address"));
Serial.flush();

IrSender.sendNEC(0x00, sCmd_Alarm_Setting, sRepeats_long);

break;
case '6': // Up button
/*
* Print current send values
*/
//Serial.println();
Serial.print(F("Send now: address=0x00, command=0x"));
Serial.print(sCmd_Up, HEX);
Serial.print(F(", repeats="));
Serial.print(sRepeats_short);
Serial.println();

//Serial.println(F("Send standard NEC with 8 bit address"));
Serial.flush();

IrSender.sendNEC(0x00, sCmd_Up, sRepeats_short);

break;
case '9': // Down button
/*
* Print current send values
*/
//Serial.println();
Serial.print(F("Send now: address=0x00, command=0x"));
Serial.print(sCmd_Down, HEX);
Serial.print(F(", repeats="));
Serial.print(sRepeats_short);
Serial.println();

//Serial.println(F("Send standard NEC with 8 bit address"));
Serial.flush();

IrSender.sendNEC(0x00, sCmd_Down, sRepeats_short);

break;
}
}
Posted by 훅크선장
, |