Help for IR remote controller

I receive the IR signal through an IR receiver and the received hexa code shows in the serial monitor.
Now I need to retransmit that signal through the IR transmitter as an NEC signal.
The problem is to use the code in the serial monitor, it has to be saved in a string variable (that’s the only way I could save it in) and then convert it into long unsigned int because IR.sendNEC( long unsigned data, 32). The code received is something of this form:
2307B446
but when i want to send it I need it to be 0x2307B446
how can i do that and how can i convert the string “2307B446” into long unsigned?

that's the only way I could save it in

That may be the only way you know how to save it. It is not the only way the data can be saved.

Where is your code?

if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
signal = (results.value,HEX);
Serial.println(signal);
}

I want to save that (results.value,HEX) from the serial.println but i didnt know how to save it as a long unsigned so i just saved it as a string but I need the long unigned, so how can i?

PaulS:

that's the only way I could save it in

That may be the only way you know how to save it. It is not the only way the data can be saved.

Where is your code?

if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
signal = (results.value,HEX);
Serial.println(signal);
}

I want to save that (results.value,HEX) from the serial.println but i didnt know how to save it as a long unsigned so i just saved it as a string but I need the long unigned, so how can i?

I want to save that (results.value,HEX) from the serial.println

That doesn't make sense. The results struct has a field, value, that contains the value of interest. value IS an unsigned long.

The Serial.print() statement is converting the value to a string representation, in hex format.

unsigned long uselessCopy = results.value;

In order to send an IR signal, I need to send a code which is in the format of the printed results.value; meaning that I want the number to be like 2307B446 for example. However, when I use the unsigned long uselessCopy = results.value, it gives me a decimal format 587707462 which is not working in the transmission process. All I need is when the port receives a hex number, it adds a “0x” before it and sends it to the transmission method. Here’s my full code to help maybe deliver my point:

#/*

  • IRremote: IRsendDemo - demonstrates sending IR codes with IRsend
  • An IR LED must be connected to Arduino PWM pin 3.
  • Version 0.1 July, 2009
  • Copyright 2009 Ken Shirriff
  • http://arcfn.com
    */

#include <IRremote.h>

IRsend irsend;

int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
unsigned long value;

void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver

}

void loop() {
while(Serial.available()>= 0){
if (Serial.read() == ‘0’) {
Serial.println(“Transmitting”);
for (int i = 0; i < 3; i++) {
irsend.sendNEC(“0x”+value, 32); // Sony TV power code
delay(40);

}
}else if (irrecv.decode(&results)) {
Serial.println(“Receiving”);
Serial.println(results.value, HEX);
value = results.value;

irrecv.resume(); // Receive the next value
}
}
}

            irsend.sendNEC("0x"+value, 32); // Sony TV power code

Rubbish. The "0x" on the front of that statement is crap. Get rid of it.

i know its crap & i know its not working but i meant to write it here to show that this is what i want to do... to concatenate 0x to the number that will be my input but i have two problems..the first is how to concat such a value (i.e 0x) when i dont want it as a string and how to have a saved variable with the hexcode as stated above