블로그 이미지
훅크선장

카테고리

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

달력

« » 2023.3
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 31

공지사항

태그목록

최근에 올라온 글

이전에 리모콘만으로 설정 가능한 LED 벽시계의 리모콘 분실로 인하여, 아두이노를 가지고 IR 리모콘을 만들어보는 별 쓸모없는 작업을 해보았다. 그런데, 가지고 있는 잡동사니 보드 중에 예전 DEFCON 컨퍼런스를 갔을때, Sparkfun 워크숍을 참가해서 받아온 Roshamglo Badge Kit을 발견했다. Roshamglo 배지 키트는 IR 송신부와 수신부, 그리고 5축 스위치를 가졌기에, 간단한 IR 리모콘으로 만들기에 최적인 보드라고 생각한 것이 실수였다!!!

 

일단 Roshamglo 배지 키트는 2017년에 만들어졌고, 일종의 재미로 만든 보드이다보니, 이젠 더이상 아두이노 IDE 상에서 소프트웨어 라이브러리 지원이 안된다. (아두이노 IDE 소프트웨어를  1.6.10~1.8.x 버전대를 사용하더라도, 보드에 대한 기본적인 소프트웨어 지원 패키지가 없기 때문에, 아두이노 IDE에서 도저히 보드를 연결할 수가 없다.)

 

여기서 포기하면, 하드웨어쟁이가 될 수 없다.

그래서, Roshamglo의 기본이 되는 ATtiny84 MCU를 기준으로 아두이노 ISP를 사용하여 프로그래밍을 시도하였다.

 

Roshamglo Badge Kit 에 대한 정보는 아래의 링크들에서...

https://learn.sparkfun.com/tutorials/roshamglo-hookup-guide/all

 

Roshamglo Hookup Guide - SparkFun Learn

Introduction <!--- ###Attributes Before you begin, make sure you have filled out all required fields found under the Attributes tab. The author is responsible for for the following: * **Title** - Pick a title that makes sense for Search Engine Optimization

learn.sparkfun.com

https://learn.sparkfun.com/tutorials/hack-your-roshamglo-badge/all

 

Hack Your Roshamglo Badge - SparkFun Learn

Introduction So you've put together your Roshamglo badge, and now you want more? Well, we can help you with that. In addition to playing infrared (IR) Rock-Paper-Scissors, the Roshamglo board can be reprogrammed with user-created code. This will allow you

learn.sparkfun.com

https://learn.sparkfun.com/tutorials/roshamglo-project-tv-b-gone/introduction

 

Roshamglo Project: TV-B-Gone - SparkFun Learn

Retired KIT-14130 The SparkFun Roshamglo is the new and fun way to play Rock-Paper-Scissors with your friends! The board uses the ATtiny84, and…

learn.sparkfun.com

 

ATtiny84  프로그래밍에 대한 정보는 다음 링크들에서...

https://github.com/SpenceKonde/ATTinyCore

 

GitHub - SpenceKonde/ATTinyCore: Arduino core for ATtiny 1634, 828, x313, x4, x41, x5, x61, x7 and x8

Arduino core for ATtiny 1634, 828, x313, x4, x41, x5, x61, x7 and x8 - GitHub - SpenceKonde/ATTinyCore: Arduino core for ATtiny 1634, 828, x313, x4, x41, x5, x61, x7 and x8

github.com

https://www.instructables.com/Arduino-Uno-to-Program-ATTINY84-Arduino-V-185/

 

Arduino Uno to Program ATTINY84 (Arduino V. 1.8.5)

Arduino Uno to Program ATTINY84 (Arduino V. 1.8.5): Using the Arduino Uno to program ATTINY84-20PU (Digikey item # ATTINY84-20-PU-ND). This Instructable shows how to use the Arduino platform to work with physically smaller processors, such as the ATtiny84

www.instructables.com

https://www.instructables.com/Program-an-ATtiny44458485-with-Arduino/

 

Program an ATtiny44/45/84/85 With Arduino

Program an ATtiny44/45/84/85 With Arduino: This tutorial gives provides the steps to set up, program, and test an ATtiny44/45/84/85 with an Arduino. It is also provides some explanations as to the inner workings of AVR chips in general.

www.instructables.com

https://www.hackster.io/350166/getting-started-with-attiny84-c920ee

 

Getting started with Attiny84

learn how to program Attiny84 with this custom Breakout board with ams1117 for basic level projects like blinking LED and stuff. By Arnov Sharma and JLCPCB.

www.hackster.io

---------------------------------------------------------------------------------------------------------------------

ATtiny84 MCU 프로그래밍 순서

 

0. ATtinyCore 보드 지원 라이브러리 설치 

Preferences... 에서 Additional boards manager URLs : 에  http://drazzy.com/package_drazzy.com_index.json를 추가해주고, Boards Manager에 가서  ATTinyCore by Spence Konde 를 설치해준다.

(이 글을 쓰는 시점에서 Arduino IDE 2.0.4에서 ATTinyCore version 1.5.2 가 설치되어 잘 동작한다.)

1. Arduino Uno를  Arduino ISP로 만든다. (File -> Examples -> 11. ArduinoISP -> ArduinoISP 선택하고, 스케치 업로드)

2. Arduino Uno와 ATtiny84(Roshamglo Badge Kit)와 연결 

    Arduino Uno의 RESET 핀과 GND 핀 사이에 10uF 커패시터를 연결 (커패시터의 짧은 다리가 GND 쪽에)

 

    Arduino Uno 핀 번호                                         Roshamglo 핀 번호 

                3.3V                <----------------->          3.3V

                GND                <----------------->          GND

                  13                  <----------------->           4 (SCK)

                  12                  <----------------->           5 (MISO)

                  11                  <----------------->            6 (MOSI)

                  10                  <----------------->            RESET

 

3. Roshamglo 에 동작시킬, ino 아두이노 프로그램 작성 

Blink 예제는 다음과 같다.

// Blinking Example

int GREEN_LED = 7; // Green LED가 연결된 핀 7번
int RED_LED = 8; // RED LED가 연결된 핀 8번

void setup(){
pinMode(GREEN_LED, OUTPUT); // Green LED를 출력으로 설정합니다.
pinMode(RED_LED, OUTPUT); // RED LED를 출력으로 설정합니다.
}
 
void loop(){
digitalWrite(GREEN_LED, HIGH); // Green LED 켜기
digitalWrite(RED_LED, LOW); // RED LED 끄기
 
delay(1000); // 1초간 유지합니다.
 
digitalWrite(GREEN_LED, LOW); // Green LED 끄기
digitalWrite(RED_LED, HIGH); // RED LED 켜기
delay(1000); // 1초간 유지합니다.
}
 
4.  Tools -> Board 설정에서  ATtinyCore -> ATtiny24/44/84(a) (No Bootloader) 선택 
                     Port는 Arduino Uno 가 연결된 포트를 지정 (/dev/cu.usbmodemXXXXXX 로 표시됨)
                     나머지 칩 설정은 기본을 그대로 둔다. 다만, Clock Source 가 8MHz (Internal) 인것을 반드시 확인한다.
      Programmer 설정에서 “Arduino as ISP”  반드시 지정 
 
5. Tools -> Burn Bootloader 선택 실행 후,
6. Sketch -> Upload using Programmer 로 프로그램을 업로드한다.
 
에러가 없이 다 정상적으로 수행되었다면, Okay~~!!  

  

Posted by 훅크선장
, |

리모콘을 잃어버린 중국제 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 훅크선장
, |