Hi guys,

I'm needing to convert some IR codes to use with arduino. The codes that I normally use are in Hex format like this:

0000 006a 002d 0001 000a 001e 000a 0047 000a 001e 000b 001e 000a 001f 000a 001e 000a 0046 000b 001e 000a 001e 000a 0047 000a 0047 000a 0046 000a 0047 000a 001e 000a 001f 000a 06a2 000a 001f 000a 0046 000b 001e 000a 001f 000a 001e 000a 0047 000a 001e 000a 0047 000a 0046 000b 001e 000a 001f 0009 001f 000a 001e 000a 0047 000a 0046 000b 06a2 000a 001e 000a 0047 000a 001f 000a 001e 000a 001f 000a 001e 000a 0047 000a 001e 000a 001f 000a 0046 000a 0047 000a 0047 000a 0046 000a 001f

but I need to convert this to something like this:

0x02FD48B7

I don't have any idea how to do this, I don't know if is a base conversion, or some conversion of type, if anybody can help me, I will be very grateful.

Just put '0x' in front of your numbers, that signals the compiler to treat it as hex, not decimal.

Your codes are printed using the example sketch IRrecvDump.ino ? The raw rappresentation of IR code? What type of code the sketch give you, "unknow" or one like NEC?

The numbers you have listed are all 16 bit integers. The number you showed separately (0x02FD48B7) is a long value (32 bits).

Each hex digit takes 4 bits (0-F), so it is easy to work out the data types you need to store the values. Up to 2 hex digits fits in a uint8_t, up to 4 in a uint16_t and up to 8 in a uint32_t.

marco_c: The numbers you have listed are all 16 bit integers. The number you showed separately (0x02FD48B7) is a long value (32 bits).

Each hex digit takes 4 bits (0-F), so it is easy to work out the data types you need to store the values. Up to 2 hex digits fits in a uint8_t, up to 4 in a uint16_t and up to 8 in a uint32_t.

Marco_C thanks for answer. Can you tell me how do I convert it? If you could give me an example would be very usefull, because there is about a month that I'm looking for a way to convert them, and I still don't know how.

0000 006a 002d 0001 000a 001e 000a 0047 000a 001e 000b 001e 000a 001f 000a 001e 000a 0046 000b 001e 000a 001e 000a 0047 000a 0047 000a 0046 000a 0047 000a 001e 000a 001f 000a 06a2 000a 001f 000a 0046 000b 001e 000a 001f 000a 001e 000a 0047 000a 001e 000a 0047 000a 0046 000b 001e 000a 001f 0009 001f 000a 001e 000a 0047 000a 0046 000b 06a2 000a 001e 000a 0047 000a 001f 000a 001e 000a 001f 000a 001e 000a 0047 000a 001e 000a 001f 000a 0046 000a 0047 000a 0047 000a 0046 000a 001f

but I need to convert this to something like this:

0x02FD48B7

It isn't clear (to me anyway) how to compress all the data in the table you showed (a total of 1536 bits) down to a single 32 bit value.

On the other hand, your final example "0x02FD48B7" could be expressed as 0x02FD and 0x48B7, or 0x48B7 and 0x02FD, depending on endianess.

Without knowing more about the data it is not clear how you would be able to compress this large amount into 32 bits.

What are you actually trying to do?

marco_c: Without knowing more about the data it is not clear how you would be able to compress this large amount into 32 bits.

What are you actually trying to do?

What I know is that the first type of hex is knows as Pronto Hex format, and your type is .CCF. I'm trying to do this because I'm developing a project about Home Automation, I already have some experience in this area, and I have a huge list of codes in this format that I spent years collecting, so I need use this codes in arduino, I found this sketch to use Pronto Hex in arduino, but I didn't understand what I should modify in the sketch, or to be clear, where I should put the hex codes in the Sketch.

The link to the Sketch: https://github.com/probonopd/arduino-infrared-pronto

What I know is that the first type of hex is knows as Pronto Hex format

“Pronto” as in the old Philips Pronto universal remote?

AWOL:

What I know is that the first type of hex is knows as Pronto Hex format

"Pronto" as in the old Philips Pronto universal remote?

Yes, those codes came from Philips Pronto.

Looks like the current sketch takes its input from the serial monitor. So you need to cut and paste the data to the serial monitor input section at the top of the window.

If you want to hard code it into the sketch then you need to modify the sketch to be triggered by something like a digital input instead of reading the data from the serial line. Then just send the array of data the way that it would be handled at the moment.

That simple

Make a routine that transform your number into a string then add “0x” in front of it. Then make it do it over and over again.

The form 0x*** is necessarily a string any way. I would use a For() and put every thing in a array of string to make it easy.