Go Down

### Topic: Help with this code and its algorithm¡¡¡¡¡¡ (Read 829 times)previous topic - next topic

#### Dani_Juarez

##### Oct 09, 2017, 09:05 pm
Good thing I'm new on this page to post hope to get it right hehe;
in short I have a code that I can not quite understand. It is a code to move a robot arm by serial port with the keyboard and store the variables and then execute them and save them if you want. what I can not understand is very well how it works every "Void" that has the code so if someone can give me a hand with a good explanation would help me a lot so I can develop their own code based on the understanding of this; here I leave them to go down I hope they can help me I would thank them very much

#### PaulS

#1
##### Oct 09, 2017, 09:26 pm
Quote
every "Void" that has the code
There are no "Void"s in your sketch. There are FUNCTIONS. That the return type is void matters not a whit.

The code seems relatively straight-forward. It is obvious that you didn't write the code. It seems equally obvious that you are trying to understand it so you can palm it off as your own.

So, you need to explain to us what YOU think it does, and we'll tell you whether you are right or wrong.

#### Dani_Juarez

#2
##### Oct 10, 2017, 12:15 am
There are no "Void"s in your sketch. There are FUNCTIONS. That the return type is void matters not a whit.

The code seems relatively straight-forward. It is obvious that you didn't write the code. It seems equally obvious that you are trying to understand it so you can palm it off as your own.

So, you need to explain to us what YOU think it does, and we'll tell you whether you are right or wrong.
exactly I did not write it and what I look for is to understand each void as they work and the algorithm that uses to move the servomotors what I am looking for is to keep degrees of each servo of my arm to save a box in principle
but my goal would be for my robot arm to be able to save 3 types of boxes of 3 different types of size so that I tell you what kind of box the 3 is and move in such a way that I save it where I program it but for that I want to understand this code so I would like very much if you can help me to understand it well to the letter

#### slipstick

#3
##### Oct 10, 2017, 12:18 am
If you don't understand any of it at all, not even that voids aren't called voids or what if or include mean, then you have no chance of successfully changing it to do something different without a lot of studying. Have you done any programming? In C++? Or what computer language?

BTW in English we use some CAPITAL letters. Also we write in sentences with punctuation. Without them it is very difficult to understand what you are trying to say.

Steve

#### jremington

#4
##### Oct 10, 2017, 02:07 amLast Edit: Oct 10, 2017, 02:08 am by jremington
Quote
what I look for is to understand each void function as they work
For a beginner, that may take hours or even days of study.

Do not be discouraged, and if you have specific questions about particular lines of code, post them on this forum.

#### Dani_Juarez

#5
##### Oct 10, 2017, 07:43 pm
If you don't understand any of it at all, not even that voids aren't called voids or what if or include mean, then you have no chance of successfully changing it to do something different without a lot of studying. Have you done any programming? In C++? Or what computer language?

BTW in English we use some CAPITAL letters. Also we write in sentences with punctuation. Without them it is very difficult to understand what you are trying to say.

Steve
If I have programmed in C in C ++ and Arduino programmed it is programmed something I understand what I do not understand is the algorithm that uses in the "void execute_automata ()" and in the "void array ()" the others I understand them inside all good but those two Voids lock me in the program

#6

#### Dani_Juarez

#7
##### Oct 10, 2017, 11:59 pm
For a beginner, that may take hours or even days of study.

Do not be discouraged, and if you have specific questions about particular lines of code, post them on this forum.
the "void execute automata ()" and in the "void translation matrix ()" I can not understand them completely well but I'll leave them here if I can help

Code: [Select]
`void matriz_de_traslacion(){  Serial.print("\n\t\t\t\t\t\t\t\tCALCULO DE MATRIZ");Serial.print(figura);  //convierte la EEPROM en matriz  for(EE=0;EE<5;EE++)  {    memor[EE]=EEPROM.read(eprom);    eprom++;  }  EE=0;  //calcular diferencias  diferencia[0] = abs (registro[0]-memor[0]);  diferencia[1] = abs (registro[1]-memor[1]);  diferencia[2] = abs (registro[2]-memor[2]);  diferencia[3] = abs (registro[3]-memor[3]);  diferencia[4] = abs (registro[4]-memor[4]);  // se elimino la sección de filtrado (no hay vibraciones causadas por los potencio metros)  //calcular limite de secciones (la mayor distancia)  limite = max(diferencia[0],diferencia[1]);  limite = max(limite,diferencia[2]);  limite = max(limite,diferencia[3]);  limite = max(limite,diferencia[4]);  Serial.print("\n\t\t\t\t\t\t\t   LIMITE=");Serial.print(limite);  //calcula dirección e incremento en grados de cada sección  if(registro[0]>memor[0]) direccion[0]=(0-diferencia[0])/limite; else direccion[0]=diferencia[0]/limite;  if(registro[1]>memor[1]) direccion[1]=(0-diferencia[1])/limite; else direccion[1]=diferencia[1]/limite;  if(registro[2]>memor[2]) direccion[2]=(0-diferencia[2])/limite; else direccion[2]=diferencia[2]/limite;  if(registro[3]>memor[3]) direccion[3]=(0-diferencia[3])/limite; else direccion[3]=diferencia[3]/limite;  if(registro[4]>memor[4]) direccion[4]=(0-diferencia[4])/limite; else direccion[4]=diferencia[4]/limite;  Serial.print("\n\t\t\t\t\t\t\t\tEJECUTANDO_MEMORIA ");Serial.print(figura);  primer_seccion=false;}and thisvoid ejecutar_automata(){  if(seccion<=limite)  {    Serial.print("\n\t\t\t\t\t\t\t\tSECCION="); Serial.print(seccion);    seccion++;    if(seccion == 1)              time = retardo*4;           else if(seccion == 10)        time = retardo*3;       else if(seccion == 20)        time = retardo*2;     else if(seccion == 30)        time = retardo*1;    if(seccion == limite-40)      time = retardo*2;    else if(seccion == limite-30) time = retardo*3;    else if(seccion == limite-20) time = retardo*4;    else if(seccion == limite-10) time = retardo*5;     registro[0]+=direccion[0];    registro[1]+=direccion[1];    registro[2]+=direccion[2];    registro[3]+=direccion[3];    registro[4]+=direccion[4];    servo1.write(registro[0]);    servo2.write(registro[1]);    servo3.write(registro[2]);    servo4.write(registro[3]);    servo5.write(registro[4]);  }  else  {    limite=0;    seccion=1;    figura++;    primer_seccion=true;  }`

Those two Voids that are inside the program that let them down and see are those who can not understand their algorithm

#### AWOL

#8
##### Oct 17, 2017, 02:05 pm
There seems to be a void (a hole, a gap) in your understanding.

Functions are called functions or subroutines, they are not called voids.