{"id":26680057,"url":"https://github.com/wagiminator/attiny13-tinyremotexl","last_synced_at":"2026-02-27T00:01:17.716Z","repository":{"id":127507580,"uuid":"378619166","full_name":"wagiminator/ATtiny13-TinyRemoteXL","owner":"wagiminator","description":"12-Button IR Remote Control","archived":false,"fork":false,"pushed_at":"2022-12-12T19:16:16.000Z","size":1030,"stargazers_count":44,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-12T11:43:09.035Z","etag":null,"topics":["arduino","attiny","attiny13","attiny13a","avr","diy","ir","pcb","project","remote"],"latest_commit_sha":null,"homepage":"https://oshwlab.com/wagiminator/attiny13-tinyremoteir-xl","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wagiminator.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-06-20T10:37:27.000Z","updated_at":"2025-02-22T08:15:54.000Z","dependencies_parsed_at":"2023-07-18T04:00:40.705Z","dependency_job_id":null,"html_url":"https://github.com/wagiminator/ATtiny13-TinyRemoteXL","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/wagiminator/ATtiny13-TinyRemoteXL","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wagiminator%2FATtiny13-TinyRemoteXL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wagiminator%2FATtiny13-TinyRemoteXL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wagiminator%2FATtiny13-TinyRemoteXL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wagiminator%2FATtiny13-TinyRemoteXL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wagiminator","download_url":"https://codeload.github.com/wagiminator/ATtiny13-TinyRemoteXL/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wagiminator%2FATtiny13-TinyRemoteXL/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29878264,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-26T23:51:21.483Z","status":"ssl_error","status_checked_at":"2026-02-26T23:50:46.793Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arduino","attiny","attiny13","attiny13a","avr","diy","ir","pcb","project","remote"],"created_at":"2025-03-26T06:19:50.765Z","updated_at":"2026-02-27T00:01:17.710Z","avatar_url":"https://github.com/wagiminator.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TinyRemoteXL - 12-Button IR Remote Control based on ATtiny13A\nTinyRemoteXL is a 12-button IR remote control based on an ATtiny13A powered by a CR2032 or LIR2032 coin cell battery.\n\n- Design Files (EasyEDA): https://easyeda.com/wagiminator/attiny13-tinyremoteir-xl\n\n![pic1.jpg](https://raw.githubusercontent.com/wagiminator/ATtiny13-TinyRemoteXL/main/documentation/TinyRemoteXL_pic1.jpg)\n![pic2.jpg](https://raw.githubusercontent.com/wagiminator/ATtiny13-TinyRemoteXL/main/documentation/TinyRemoteXL_pic2.jpg)\n\n# Hardware\nThe basic hardware is similar to the 5-button [TinyRemote](https://github.com/wagiminator/ATtiny13-TinyRemote). The main difference is that the ATtiny13 has to query 12 buttons here. There are various options for using a larger number of buttons with just a few pins. However, most of them do not meet the following conditions:\n\n- there are only four pins available for twelve buttons,\n- a keystroke must trigger an asynchronous interrupt to wake the ATtiny from deep sleep mode,\n- the circuit must not consume any electricity as long as no button is pressed.\n\nA combination of voltage dividers and a couple of diodes does the trick:\n\n![wiring.png](https://raw.githubusercontent.com/wagiminator/ATtiny13-TinyRemoteXL/main/documentation/TinyRemoteXL_wiring.png)\n\nIf, for example, button 4 is pressed, pin PB0 is pulled to ground via the corresponding diode and a pin change interrupt is triggered, which wakes up the ATtiny. The diodes prevent the 4k7 resistors of the voltage divider from shorting out. The voltage that can be measured at PB2 via the ADC results from the supply voltage divided by the 10k resistor on the upper side and two 4k7 resistors (= 9k4) on the lower side. This value depends on the key pressed.\n\n# Software\n## IR Protocol Implementation\nThe implementation for the NEC, SAMSUNG, SONY and RC-5 protocol is taken from [TinyRemote](https://github.com/wagiminator/ATtiny13-TinyRemote). Refer to this project for a complete explanation.\n\n## Setting the IR Codes\nBefore compiling you have to define the IR commands for each button. Different protocols and device addresses can be used. Several codes can also be assigned to a single key, separated by semicolons.\n\n```c\n#define KEY1  NEC_sendCode(0x04,0x08)     // LG TV Power: addr 0x04, cmd 0x08\n#define KEY2  RC5_sendCode(0x00,0x0B)     // Philips TV Power: addr 0x00, cmd 0x0B\n#define KEY3  SON_sendCode(0x01,0x15,12)  // Sony TV Power: addr 0x01, cmd 0x15, 12-bit version\n#define KEY4  SAM_sendCode(0x07,0x02)     // Samsung TV Power: addr: 07, cmd: 02\n#define KEY5  NEC_sendCode(0xAB04,0x08);SON_sendCode(0xE401,0x15,20)\n[...]\n```\n\n## Button Detection\nIf a key has been pressed, a pin change interrupt is triggered and the ATtiny is brought out of sleep mode. The pressed key is then identified via the voltage divider between the individual keys using the ADC of the ATtiny.\n\n```c\n// Pin assignments\n#define BINT1_PIN   PB0       // interrupt pin for buttons 1..6\n#define BINT2_PIN   PB3       // interrupt pin for buttons 7..12\n#define BADC1_AP    1         // ADC port for buttons 1..6\n#define BADC2_AP    2         // ADC port for buttons 7..12\n\n// Button ADC thresholds\nconst uint8_t THRESHOLDS[] PROGMEM = {217, 173, 158, 136, 103, 41, 0};\n\n// ADC read button row and return button number\nuint8_t readButtonRow(uint8_t port) {\n  PRR     = 0;                            // power on ADC\n  ADMUX   = (1\u003c\u003cADLAR) | port;            // set port, Vcc as reference, 8-bit sample\n  ADCSRA |= (1\u003c\u003cADEN) | (1\u003c\u003cADSC);        // enable ADC and start sampling\n  while (ADCSRA \u0026 (1\u003c\u003cADSC));             // wait until sampling complete\n  uint8_t raw = ADCH;                     // read sampling result (8 bits)\n  ADCSRA \u0026= ~(1\u003c\u003cADEN);                   // disable ADC\n  PRR     = 1\u003c\u003cPRADC;                     // shut down ADC\n  uint8_t  button = 0;                    // figure out button number\n  while (raw \u003c pgm_read_byte(\u0026THRESHOLDS[button])) button++;\n  return button;                          // return button number\n}\n\n// Read and return button number (0 = no button)\nuint8_t readButton(void) {\n  uint8_t  button = 0;                    // start with number 0\n  if (~PINB \u0026 (1\u003c\u003cBINT1_PIN)) button = readButtonRow(BADC1_AP);\n  else if (~PINB \u0026 (1\u003c\u003cBINT2_PIN)) {\n    button = readButtonRow(BADC2_AP);\n    if (button) button += 6;\n  }\n  return button;                          // return button number\n}\n\n// Main function\nint main(void) {\n  [...]  \n  // Setup ADC to read button values\n  ADCSRA = (1\u003c\u003cADPS1)|(1\u003c\u003cADPS0);       // set ADC prescaler 8\n  [...]\n  // Main loop\n  while(1) {\n    sleep_mode();                       // sleep until button is pressed\n    _delay_ms(1);                       // debounce\n    uint8_t button = readButton();      // read button number\n    switch (button) {                   // send corresponding IR code\n      case  1:  KEY1;  break;\n      case  2:  KEY2;  break;\n      [...]\n      default: break;\n    }\n  }\n}\n\n// Pin change interrupt service routine\nEMPTY_INTERRUPT (PCINT0_vect);          // nothing to be done here, just wake up from sleep\n```\n\n## Power Saving\nThe code shuts down unused peripherals and utilizes the sleep mode power down function. It wakes up on every button press by pin change interrupt.\n\n```c\n// Disable unused peripherals and prepare sleep mode to save power\nACSR  =  1\u003c\u003cACD;                      // disable analog comperator\nDIDR0 = ~BT_MASK \u0026 0x1F;              // disable digital intput buffer except button INT\nPRR   =  1\u003c\u003cPRADC;                    // shut down ADC\nGIMSK =  1\u003c\u003cPCIE;                     // turn on pin change interrupts\nPCMSK =  BT_MASK;                     // turn on interrupt on button pins\nsei();                                // enable global interrupts\nset_sleep_mode(SLEEP_MODE_PWR_DOWN);  // set sleep mode to power down\n```\n\nAs long as no button is pressed, the ATtiny remains in sleep mode power down and consumes a current of around 100nA at a voltage of 3V. The typical capacity of a CR2032 battery is 230mAh. This results in a theoretical battery life of 2.3 million hours or 269 years. In real life, of course, no battery will last that long due to its self-discharge. When the button is pressed, peaks of up to 30mA are consumed. The diagram below shows the course of the current consumption when a button is pressed according to a measurement with the [Power Profiler Kit II](https://www.nordicsemi.com/Products/Development-hardware/Power-Profiler-Kit-2):\n\n![current.png](https://raw.githubusercontent.com/wagiminator/ATtiny13-TinyRemoteXL/main/documentation/TinyRemoteXL_current.png)\n\n## Timing Accuracy\nThe accuracy of the internal oscillator of the ATtiny13 is +/-10% with the factory calibration. Usually this is sufficient for an infrared remote control. Slight deviations in timing are tolerated by the receiver, since cheap remote controls are usually not more accurate. Nevertheless, it is recommended to [manually calibrate](https://github.com/wagiminator/ATtiny84-TinyCalibrator) the internal oscillator and set the corresponding OSCCAL value at the beginning of the code.\n\n```c\n// oscillator calibration value (uncomment and set if necessary)\n#define OSCCAL_VAL  0x48\n```\n\n## Compiling and Uploading\nSince there is no ICSP header on the board, you have to program the ATtiny either before soldering using an [SOP adapter](https://aliexpress.com/wholesale?SearchText=sop-8+150mil+adapter), or after soldering using an [EEPROM clip](https://aliexpress.com/wholesale?SearchText=sop8+eeprom+programming+clip). The [AVR Programmer Adapter](https://github.com/wagiminator/AVR-Programmer/tree/master/AVR_Programmer_Adapter) can help with this.\n\n### If using the Arduino IDE\n- Make sure you have installed [MicroCore](https://github.com/MCUdude/MicroCore).\n- Go to **Tools -\u003e Board -\u003e MicroCore** and select **ATtiny13**.\n- Go to **Tools** and choose the following board options:\n  - **Clock:**  1.2 MHz internal osc.\n  - **BOD:**    BOD disabled\n  - **Timing:** Micros disabled\n- Connect your programmer to your PC and to the ATtiny.\n- Go to **Tools -\u003e Programmer** and select your ISP programmer (e.g. [USBasp](https://aliexpress.com/wholesale?SearchText=usbasp)).\n- Go to **Tools -\u003e Burn Bootloader** to burn the fuses.\n- Open the TinyRemoteXL sketch and click **Upload**.\n\n### If using the precompiled hex-file\n- Make sure you have installed [avrdude](https://learn.adafruit.com/usbtinyisp/avrdude).\n- Connect your programmer to your PC and to the ATtiny.\n- Open a terminal.\n- Navigate to the folder with the hex-file.\n- Execute the following command (if necessary replace \"usbasp\" with the programmer you use):\n  ```\n  avrdude -c usbasp -p t13 -U lfuse:w:0x2a:m -U hfuse:w:0xff:m -U flash:w:tinyremotexl.hex\n  ```\n\n### If using the makefile (Linux/Mac)\n- Make sure you have installed [avr-gcc toolchain and avrdude](http://maxembedded.com/2015/06/setting-up-avr-gcc-toolchain-on-linux-and-mac-os-x/).\n- Connect your programmer to your PC and to the ATtiny.\n- Open a terminal.\n- Navigate to the folder with the makefile and sketch.\n- Run `PROGRMR=usbasp make install` to compile, burn the fuses and upload the firmware (change PROGRMR accordingly).\n\n# References, Links and Notes\n1. [TinyRemote](https://github.com/wagiminator/ATtiny13-TinyRemote)\n2. [TinyRemote RF](https://github.com/wagiminator/ATtiny13-TinyRemoteRF)\n3. [IR remote control explanations by San Bergmans](https://www.sbprojects.net/knowledge/ir/index.php)\n4. [IR remote control by Christoph Niessen (german)](http://chris.cnie.de/avr/tcm231421.html)\n5. [IR remote control detective by David Johnson-Davies](http://www.technoblogy.com/show?24A9)\n6. [Infrared communication concepts (altium.com)](https://techdocs.altium.com/display/FPGA/Infrared+Communication+Concepts)\n7. [NEC decoder based on  ATtiny13A](https://github.com/wagiminator/ATtiny13-TinyDecoder)\n8. [OSC Calibrator](https://github.com/wagiminator/ATtiny84-TinyCalibrator)\n9. [ATtiny13A datasheet](http://ww1.microchip.com/downloads/en/DeviceDoc/doc8126.pdf)\n\n# License\n![license.png](https://i.creativecommons.org/l/by-sa/3.0/88x31.png)\n\nThis work is licensed under Creative Commons Attribution-ShareAlike 3.0 Unported License. \n(http://creativecommons.org/licenses/by-sa/3.0/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwagiminator%2Fattiny13-tinyremotexl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwagiminator%2Fattiny13-tinyremotexl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwagiminator%2Fattiny13-tinyremotexl/lists"}