IR Codes

From Leo's Notes
Last edited on 30 December 2021, at 01:19.

LED Strip Driver IR[edit | edit source]

RGB LED Strip Remote
RGB LED Strip Remote

I have a LED strip driver which I wanted to try driving with an Arduino. Using a LCR TC1, the remote control's first button can be decoded as UserCode: 00EF DataCode: 00FF. The last button is decoded as UserCode: 00EF DataCode: 17E8.

After some searching, the codes are of the NEC type. Using the Arduino-IRremote library and some trial an error it looks like the code data is sent as a 4 byte word. The first 2 bytes are for the button number and the last 2 bytes are the inverse of the number. The two 2 byte values are in little endian and the bits are reversed. That is. 0x01ABCDEF is encoded as 0xAB01 and 0xEFCD with each section's binary reversed. For example. 0x00EF is encoded as 0xEF00, which is 1110111100000000 in binary and when reversed is 0000000011110111 or 0x00F7.

The Arduino code to sent a button number is given below.

void send(int button) {
	int value = 0;
	
	int check = 0xff - button;
	
	// button is on 1st byte
	for (int x = 0 ; x < 8; x++) {
		// button byte reversed
		value |= (((button & (0x01 << x)) >> x) << (7 - x)) << 8;
		
		// check byte reversed
		value |= ((check & (0x01 << x)) >> x) << (7 - x);
	}
	
	Serial.print("Sending ");
	Serial.print(i);
	Serial.println();
	
	irsend.sendNEC(0x00F70000 + value, 32);
	delay(50);
}

Unfortunately, sending codes outside of the 24 has no effect on the driver. The reason I tested this was because I wanted to control the RGB values which other remotes for other drivers have.