lundi 28 novembre 2016

How to wait for a value until it performs the next syntax in VB.NET?

I am obtaining height data from my sensor and here is my code:

If Sensor1 = 5 Or Sensor1 = 6 Or Sensor1 = 7 Then
   If Sensor1 >= 13 Then
      flagCtr1 = 1
   End If
ElseIf Sensor1 = 8 Or Sensor1 = 9 Then
   If Sensor1 >= 13 Then
      flagCtr1 = 2
   EndIf
ElseIf Sensor1 = 10 Then
   If Sensor1 >= 13 Then
      flagCtr1 = 3
   End If
End If

Basically what I want to happen is, for example, when my sensor detected the height 7, it will wait for the value greater than or equal 13 before it performs the flagCtr = 1. I tested this code and nothing happens.

This is my dilemma. This is an example of how I read the height where 15 is the height where there is no object placed below the sensor

15
15
15
7 - object was placed
7
7
7
7
8 - object is being removed
15
15
15

everytime I will remove the object it goes to a certain number that is also in one of the conditions. My problem is the latest height data is being read not the data that was read at a time interval. So what I want to do is that I will wait for the sensor to go back to the value greater than or equal 13 before it performs the next instruction.

Sorry for a long post, I really need help, this is my thesis. Thank you so much

Aucun commentaire:

Enregistrer un commentaire