dimanche 5 novembre 2017

How do I check if values in array are in between a max and min and then do something

Hello I am having problems checking if my values are in between the max and min tolerances and if so to do something. When I run my code it just checks one value by that the max and min ranges individually. My problem is I need it to make sure every value is within range then complete a task.

    for j in range(3):
       if list[j] <= max[j] and list[j] >= min[j] and moistureSum < 419 and moistureSum2 < 419:
          a.digitalWrite(inputGateSignal, a.LOW)
          print 'Valve 1 opening'
       # update_BallValve1 = ("INSERT INTO BallValve1 " "(ballvalve1) " "VALUES (%s)")
        #cursor.execute(update_BallValve1, (open,))
          print 'Ball Valve 1 status updated'
          time.sleep(2)
          a.digitalWrite(inputGateSignal2, a.HIGH)
          print 'Valve 2 opening'
          #update_BallValve1 = ("INSERT INTO BallValve2 " "(ballvalve2) " "VALUES (%s)")
        #cursor.execute(update_BallValve1, (open,))
          print 'Ball Valve 2 status updated'
          time.sleep(2)


       else:
         a.digitalWrite(inputGateSignal, a.LOW)
         print 'Valve 1 closing'
       #update_BallValve1 = ("INSERT INTO BallValve1 " "(ballvalve1) " "VALUES (%s)")
        #cursor.execute(update_BallValve1, (close,))
         print 'Ball Valve 1 status updated'
         time.sleep(2)
         a.digitalWrite(inputGateSignal2, a.LOW)
         print 'Valve 2 closing'
        #update_BallValve1 = ("INSERT INTO BallValve2 " "(ballvalve2) " "VALUES (%s)")
        #cursor.execute(update_BallValve1, (close,))
         print 'Ball Valve 2 status updated'
         time.sleep(2)

Aucun commentaire:

Enregistrer un commentaire