0

I'm doing a program that starts the measuring process, using an HX711 when the door lock magnetic sensor spits and, when ends the measuring process when the door lock magnetic sensor joins.

if (analogRead(A0) > 50){
    scale.power_up();
    lcd.setCursor(0, 4);
    lcd.print("Peso: ");
    lcd.print(scale.get_units(), 3);
    Serial.print(scale.get_units(), 3);
    lcd.print(" kg");
    Serial.print("\t");   

    myRTC.updateTime();
    Serial.print(myRTC.dayofmonth);                                                                     
    Serial.print("/");                                                                                      
    Serial.print(myRTC.month);                                                                              
    Serial.print("/");                                                                                      
    Serial.print(myRTC.year);                                                                              
    Serial.print("  ");                                                                                     
    Serial.print(myRTC.hours);                                                                              
    Serial.print(":");                                                                                      
    Serial.print(myRTC.minutes);                                                                            
    Serial.println("");
    delay(3250);
    digitalWrite(pinR1, LOW);
    lcd.clear();
    lcd.setCursor(0, 1);
    delay(2000);

    if( analogRead(A0) < 50){
    lcd.print("   Peso Registado   ");
    delay(3500);
    lcd.clear();
    lcd.setCursor(0, 1);
    lcd.print(" O planeta agradece ");
    lcd.setCursor(0, 2);
    lcd.print("    a sua ajuda!    ");
    delay(3000);
    lcd.clear();
    }  

    lcd.print("------TI-Trash------");
    lcd.setCursor(0, 1); 
    myRTC.updateTime();     
    lcd.print("   ");
    lcd.print(myRTC.dayofmonth); 
    lcd.print("/");                                                                                                                                                   
    lcd.print(myRTC.month);                                                                             
    lcd.print("/");                                                                                     
    lcd.print(myRTC.year);                                                                              
    lcd.print("  ");                                                                                   
    lcd.print(myRTC.hours);                                                                            
    lcd.print(":");                                                                                     
    lcd.print(myRTC.minutes);                                                                                                                                                
    lcd.setCursor(0, 4);
    lcd.print("LOADING...");
    delay(2500);
    lcd.setCursor(0, 4);
    lcd.print(">APROXIME SEU CARTAO");
    }
 }

The problem is that I don't know how can I control the end of the measuring process because the process ends after a few seconds.

How can I controll the end of the measuring process

0

You need a variable for the state of the door. If state of the door is closed and the sensor shows that the door is open that is the moment where the you update the state of the door to open and start to measure. When the door state is open and the sensor shows that it is closed that is the moment when you change the state of the door to closed and stop measure.

  • Can you help me with examples of the code you're talking about? – Tiago Gonçalves Sep 13 '18 at 10:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.