Muy buenas, estoy teniendo complicaciones para entender la parte de los for de este programa, me podriais ayudar, pero solo no entiendo los for, lo demas si:
int pot[2] = {0, 0};
int ulPot[2] = {0, 0};
void setup(){
Serial.begin(57600);
}
void loop() {
for(int i = 0; i < 2 ; i++){
pot[i] = analogRead(i) / 8;
delay(10);
}
for(int i = 0; i < 2; i++){
if(pot[i] != ulPot[1]){
ulPot[i] = pot[i];
}
}
}
Te doy varios consejos.
- Indenta el codigo, luego te sera mucho mas legible
- Usa algún simulador básico como SimulIDE o Tinkercad.
- Pon tantos print() como sean necesarios para que veas en el monitor serie lo que ocurre.
Algo asi mira:
int pot[2] = {0, 0};
int ulPot[2] = {0, 0};
void setup(){
Serial.begin(57600);
}
void loop() {
for(int i = 0; i < 2 ; i++){
Serial.print("i = ");
Serial.print(i);
pot[i] = analogRead(i) / 8;
Serial.print(" Pot(");
Serial.print(i);
Serial.print(") = ");
Serial.println(pot[i]);
delay(10);
}
for (int i = 0; i < 2; i++){
if (pot[i] != ulPot[1]){
ulPot[i] = pot[i];
}
}
}
Busca en Youtube videos tutoriales de Arduino en español. Hay muchos.