bool espera = true;
int dada1, dada2;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.setTimeout(10);
Serial.println("Àrea d'un quadrat");
Serial.println("mida del costat: ?");
while(espera){
if(Serial.available()){
//dada1 = int(Serial.read());
dada1 = Serial.parseInt();
Serial.read();
espera = false;
}
}
espera = true;
Serial.print("Dada 1: ");
Serial.println(dada1);
delay(1000);
Serial.println("mida del base: ?");
while(espera){
if(Serial.available()){
//dada2 = int(Serial.read());
dada2 = Serial.parseInt();
espera = false;
}
}
Serial.print("Dada 2: ");
Serial.println(dada2);
Serial.print("Resposta: ");
Serial.println(dada1*dada2);
Serial.println("Fi");
}
void loop() {
// put your main code here, to run repeatedly:
}