Three-command remote control with a program of 290 16-bit words

Original author: Gerhard Schmidt
  • Transfer
  • Tutorial


The ATtiny13 device, controlled by a program of 290 16-bit words written in assembler, remembers the codes of the six buttons on the remote control and turns on / off the three loads. Scheme:



The standard TSOP1740 IR receiver uses inverse logic, and this is taken into account in the program. Received signals cause an INT0 interrupt. The resistor is needed to untie the IR receiver from the microcontroller during the firmware upload.

The procedure for teaching the device button codes is as follows. Turn on the power with the button pressed at the PB3 input (then you can release it). The first load will briefly turn on and off immediately. We press the button on the remote control, with which we want to turn on the first load. As soon as the remote sends the same code twice (this happens if you hold the button down for at least a couple of seconds), the first load will turn on for five seconds and turn off. And the second will turn on briefly and also immediately turn off. We train the device for the code of the button for turning on the second load. Then the third. Now we are doing the same sequentially with the button codes, with which we want to disconnect the loads. The program will write the codes to the EEPROM, now you need to turn the power off and on, but do not press the button on the PB3 input. The device will go into operating mode, in which you can manage loads.

When checking loads, the LEDs are connected via resistors. After making sure that everything works, we connect to the outputs the keys that control the relay. As can be seen from the circuit of any of the three keys, indicator LEDs with resistors are left in place for convenience:



Actually, there should be NPN transistors connected by emitters to the common wire, but the author works like that. Loads can be, for example, LED lamps with color temperatures of 2700, 4000 and 6400 K. You can switch them manually according to circadian rhythms, without relying on automation.

Assembler code: no HTML-format and with that .

Confirmation that it was possible to meet 290 16-bit words:

gavrasm Gerd's AVR assembler version 3.5 (C)2015 by DG4FAC
----------------------------------------------------------
Source file: 12_IR-Rx_Switch.asm
Hex file:    12_IR-Rx_Switch.hex
Eeprom file: 12_IR-Rx_Switch.eep
Compiled:    23.11.2016, 23:23:05
Pass:        2
     1: ;
     2: ; ***************************************
     3: ; * IR-Switch 3-Channel with ATtiny13   *
     4: ; * (C)2016 by www.avr-asm-tutorial.net *
     5: ; ***************************************
...
Program             :      290 words.
Constants           :        0 words.
Total program memory:      290 words.
Eeprom space        :       13 bytes.
Data segment        :       29 bytes.
Compilation completed, no errors.
Compilation ended 23.11.2016, 23:23:05

Also popular now: