user24283: It's a basic one: I have two values from two different analogRead pins:
int val1;
int val2;

For example, val1 = 10 and val2 = 10. How could I put these two values into a variable val3 = val1 + val2 that will give the answer 1010, instead 20 ?

user10394: If you are reading from the analog pins then the values are 10 bits (not 8 as suggested above).  Are you looking at concatenating 2 10 bit numbers or 2 16 bit numbers or are you using a zero or duo in which case they could be 12 bit numbers.
In any case:
const int BITMASK = 0x3FF;  // 10 bits = 0x3FF, 12 = 0xFFF, 16 = 0xFFFF
const int BITWIDTH = 10;
long result = ((value1 & BITMASK) << BITWIDTH) | (value2 & BITMASK);

I suspect it won't give you the answer you want, but...

user4143: It sounds to me, from your comments, that what you want to do is turn this:
myRadio.transmit(val1);
myRadio.transmit(val2);

into something more like this:
myVal = join(val1, val2);
myRadio.transmit(myVal);

That's all pseudocode of course, and those functions are in themselves nonsense, but it serves to illustrate.
So you want to turn two values into one single block of data for sending thus reducing the overall transmission overhead of the packet (one large packet instead of two smaller packets). 
What you are actually looking for is called a struct and looks something like this:
struct MyData {
    int val1;
    int val2;
};

That creates a new variable type which contains two sub-variables in it. You then use it like any other variable:
struct MyData data;

You can then get at the values inside it with:
data.val1 = analogRead(A1);
data.val2 = analogRead(A2);

And the whole thing can be transmitted in one block with whatever functions your RF library provides:
myRadio.transmit(&data, sizeof(struct MyData));

Receiving at the other end is just the same - as long as the receiving end has the same structure. Receive into a MyData structure variable and you can get at the individual sub-variables:
struct MyData data;
myRadio.receive(&data, sizeof(struct MyData));
Serial.print(data.val1);
Serial.print(",");
Serial.println(data.val2);

Of course, you need to read up on whatever library it is you're using to do your transmitting and receiving to find the actual correct functions to call to transmit and receive a block of data like that...

24283: <p>It's a basic one: I have two values from two different analogRead pins:</p>

<pre><code>int val1;
int val2;
</code></pre>

<p>For example, val1 = 10 and val2 = 10. How could I put these two values into a variable val3 = val1 + val2 that will give the answer 1010, instead 20 ?</p>
 10394: <p>If you are reading from the analog pins then the values are 10 bits (not 8 as suggested above).  Are you looking at concatenating 2 10 bit numbers or 2 16 bit numbers or are you using a zero or duo in which case they could be 12 bit numbers.</p>

<p>In any case:</p>

<pre><code>const int BITMASK = 0x3FF;  // 10 bits = 0x3FF, 12 = 0xFFF, 16 = 0xFFFF
const int BITWIDTH = 10;
long result = ((value1 &amp; BITMASK) &lt;&lt; BITWIDTH) | (value2 &amp; BITMASK);
</code></pre>

<p>I suspect it won't give you the answer you want, but...</p>
 4143: <p>It sounds to me, from your comments, that what you want to do is turn this:</p>

<pre><code>myRadio.transmit(val1);
myRadio.transmit(val2);
</code></pre>

<p>into something more like this:</p>

<pre><code>myVal = join(val1, val2);
myRadio.transmit(myVal);
</code></pre>

<p>That's all pseudocode of course, and those functions are in themselves nonsense, but it serves to illustrate.</p>

<p>So you want to turn two values into one single block of data for sending thus reducing the overall transmission overhead of the packet (one large packet instead of two smaller packets). </p>

<p>What you are actually looking for is called a <em>struct</em> and looks something like this:</p>

<pre><code>struct MyData {
    int val1;
    int val2;
};
</code></pre>

<p>That creates a new variable type which contains two sub-variables in it. You then use it like any other variable:</p>

<pre><code>struct MyData data;
</code></pre>

<p>You can then get at the values inside it with:</p>

<pre><code>data.val1 = analogRead(A1);
data.val2 = analogRead(A2);
</code></pre>

<p>And the whole thing can be transmitted in one block with whatever functions your RF library provides:</p>

<pre><code>myRadio.transmit(&amp;data, sizeof(struct MyData));
</code></pre>

<p>Receiving at the other end is just the same - as long as the receiving end has the same structure. Receive into a MyData structure variable and you can get at the individual sub-variables:</p>

<pre><code>struct MyData data;
myRadio.receive(&amp;data, sizeof(struct MyData));
Serial.print(data.val1);
Serial.print(",");
Serial.println(data.val2);
</code></pre>

<p>Of course, you need to read up on whatever library it is you're using to do your transmitting and receiving to find the actual correct functions to call to transmit and receive a block of data like that...</p>
