I am interested in seeing the finished code if you would share it.
I have an IR NEC receive library in post #1.
It uses interrupts to decode RX bits.
Sure… it’s attached. You can use this code to send any IR data you wish.
The data for the IR stream is formatted like this:
VALUE = (WIDTH / 25)
VALUE |= 0x8000 (ONLY if the IR LED should be on)
LAST VALUE = 0 (flags “end of table”).
The value “25” comes from the IR carrier frequency (1/40000)*1e6 = 25 (microseconds)
The IR carrier frequency (ISR rate) is DESIRED_CARRIER_FREQ * 2
The reason that it’s X2 is because each “on/off” pulse of the IR LED is 1/80000 on and 1/80000 off.
Looking at the code, you should have no problem understanding how it works, or how to make your own data tables to send other codes.
The Makefile is included for it (it’s not an Arduino INO file, but a CPP file that you compile with AVR-GCC). Use these commands with the makefile:
make - just build/rebuild the code
make clean - erase all intermediate files and rebuild all
make all - build code, then use AVRDUDE to send it to the CPU
At the top of the Makefile are a few defines you will need to change if you want to use a different processor. All of the fuses (the 3, plus fock/unlock) are also set when programming from the Makefile.
The code, as you will see, is meant to be continuously powered and triggered by a pushbutton. After sending out the IR code, it goes back to sleep.
Any questions, please feel free.
ir.zip (5.91 KB)