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){
//read the incoming byte
//Serial.println("Hay algo:");
tmp=Serial.read();
//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){*
- //read the incoming byte*
- //Serial.println("Hay algo:");*
- tmp2=Serial.read();*
- //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;