This program was written for a Jet AFS-1000B Air Filtration System. There are a number of look-alike units for sale that also use IR remotes. I don't know if the control codes are the same, but it is perhaps likely. I made good use of my Siglent SDS-1202X-E Digital Storage Oscilloscope to capture the remote control signals and check my program that reproduces them. The waveforms were captured and recorded with the EasyScopeX software from Siglent. This project is not rocket science by any means, but it gave me a chance to use my new scope and get back to Arduino programming - crude though it is - I am annoyed at myself for using global variables so freely for one thing. But this was a quick and dirty project to meet a need - and is quite useful for us.
The Jet IR remote sends bursts of pulses that are composed of 9 microseconds on and 17 microseconds off cycles. This is close to the limits of the delayMicroseconds() function, but using delayMicroseconds(7) and delayMicroseconds(15) combined with the loop control and I/O overhead is very close.
When the remote ON/OFF button is pressed, the IR LED sends a continuous 9 millisecond burst of these cycles. This is followed by a 4.6 mS delay, then a burst of 21 of these cycles lasting about 550 microseconds, followed by a 1.7 mS delay. Then there are a series of what I call Fast and Slow pulses that are comprised of the 21 cycle burst followed by a delay of either 580 microseconds or 1.7 milliseconds. The sequence is 9 Fast, 8 Slow, 9 Fast, 6 Slow, and then a delay of 40 mS before the same pattern is repeated for as long as the button is pressed. This same pattern toggles the air cleaner on or off. I have programmed for three repeats of the pattern using the IR LED half of an optical interrupter just to insure that the code is received should a fly go by or some other momentary interruption of the IR beam occurs.
The program determines the state of the lights in the workshop by using the phototransistor half of an optical interrupter that is taped with black electrical tape onto one of the workshop lights. The idea is that just turning on the basement lights when popping down for a minute or so for a screwdriver, would not be sufficient to activate the air cleaner. The workshop lights (where the dust generating table saw and such are) must be turned on to activate sending the ON code. Once on, the program loops approximately once a second to check the light status. If the light is still on, it just loops. If the lights are turned off, the program delays for approximately 15 minutes to clear the air following a workshop session. If the lights were to be turned back on in this period, the air cleaner would just stay on.
If the lights are turned off, and after the 15 minute clearing time has expired, if the lights are not turned back on for a period of time (about 24 hours in this program), then the air cleaner will be turned on for about 15 minutes and then off again. This periodic cleaning will continue until the workshop lights are once again turned on.
The Arduino and IR LED are placed at the outlet where the air cleaner is plugged in with an unobstructed path to the back of the unit. A length of two-conductor wire connects the phototransistor to the Arduino. In this program I am using the LED_BUILTIN output to control the IR LED through a 220 ohm pullup. This let me see the otherwise invisible output occurring. I also used the serial monitor to check the light levels from the phototransistor. When secured with black electrical tape, the ADC (using A2) goes from near zero with the light off to nearly 1024 with it on, so the threshold was set at 512.