# How to add two digits

Hi, I am new with arduino and I am doing different exercises. I am trying to add two digits of more than one number. I start writting the numbers until i touch the intro and then the second digit doing the same.
The problem is that i dont know how to program that enter and save the value in an array and after that carry out the sum of both digits. Can someone help me? Thank you.
I put here the code i have until now:

char incomingByte[15]; //for incoming serial data
char incomingByte2[15];
char tmp;
char tmp2;
char batuketa[15];

int j;
int i;

void setup() {
Serial.begin(9600); //opens serial port, sets data rate to 9600 bps
i = 0;
j=0;
int incomingByte[15];
int incomingByte2[15];
int batuketa[15];
}

void loop() {
// put your main code here, to run repeatedly:
//send data only when you receive data
i = 0;
do
{
if(Serial.available()>0){
//Serial.println("Hay algo:");
//Serial.print(tmp);
incomingByte*=tmp;*

• // Serial.print(incomingByte); *
• i=i+1; *
• } *
• }while(char(incomingByte[i-1]!='j'));*
• Serial.println("He leido:");*
• Serial.println(incomingByte);*
• Serial.println("se acabo");*

j = 0;

• do*
• {*
• if(Serial.available()>0){*
• //Serial.println("Hay algo:");*
• //Serial.print(tmp);*
• incomingByte2[j]=tmp;*
• // Serial.print(incomingByte); *
• j=j+1; *
• } *
• }while(char(incomingByte2[j-1]!='j'));*
• Serial.println("He leido:");*
• Serial.println(incomingByte2);*
• Serial.println("se acabo");*

}
batuketa=incomingByte+incomingByte2;

`````` int incomingByte[15];
int incomingByte2[15];
``````

Stupid names. Using a type (Byte) in a name of a variable that is NOT that type is NEVER a bright thing to do.

Creating two arrays - one set local to setup() and one set global - is NOT a bright thing to do.

Creating variables in one scope that have the same names as those in another scope, but different types, is especially stupid.

Creating local variables that immediately go out of scope is not very useful.

Numbering one variable in a set but not the other is not too bright, either.

Posting code without code tags isn't the mark of the sharpest crayon in the box. Read the stickies at the top of the forum. Fix your post, and put your code in code tags. It most certainly does NOT look like what you posted.

It isn't clear what your problem is. You have two do/while loops that appear to do nearly the same thing, uselessly storing the byte you read in a variable, and then storing the variable in an array.

At the end, you have two arrays that are not strings, because they are not NULL terminated. You then try to add two strings.

Post a video of you using a calculator to ADD "elephant" and "twentyone". Show the results. Then, we can show you how to do the same thing.