Answers.Body: <p>Here's some pseudocode that does what you need:  </p>
  
  <pre><code>Reset timer
  Loop block:
      Sensor block, output logical TRUE when condition is reached
      Timer block, output logical TRUE when X seconds have passed
      Logic block, outputs logical TRUE if sensor OR timer is true
  End loop when it receives TRUE from the Logic block.
  Switch block:
      if sensor = condition, SEQUENCE B
  End switch
  SEQUENCE A
  </code></pre>
  
  <p>The sensor and timer blocks' logical data wires are connected to the logic block. The logic block is set to "OR", which ends the loop if either one is true. Then you use a switch to decide whether or not to execute SEQUENCE B, and after that, SEQUENCE A happens regardless.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-03T11:53:19.693Z
Answers.Text: Thanks for help !! I'll try tonight your solution ! thanks to all
Answers.UserDisplayName: Zerop
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-04T03:20:58.510Z
Answers.Text: @Zerop No problem! Just to elaborate a bit, the key here is that you're using a loop (instead of a wait block) to wait until either logic signal is true. Then after the loop, you use a switch to act based on which condition ended the loop. You could easily extend this to more than 2 conditions, or use it to wait until BOTH conditions are true, etc. Just a cool programming trick to keep in mind for the future.
Answers.UserDisplayName: MindS1
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-04T07:56:06.137Z
Answers.Text: MindS1 thanks a lot !!!!! it's worked perfectly !!!! 
  I had almost arrived near it. What was wrong was the switch block. I used the switch block waiting for a true logical condition instead of waiting for the sensor. Now it works perfectly. Thank you so much for the invaluable help !!
Answers.UserDisplayName: Zerop
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-02T19:18:52.183Z
Answers.LastActivityDate: 2019-01-02T19:18:52.183Z
Answers.UserDisplayName: MindS1
Answers.Body: <p>One way would be to use a loop with a counter and a built-in waiting period. In each iteration check the sensor readings: if the value indicates the presence of a hand, exit the loop and start sequence B. Otherwise increment a counter and wait for some time. Finally, if the value of the counter indicates that the 10 seconds have passed, execute sequence A.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-02T13:52:10.727Z
Answers.LastActivityDate: 2019-01-02T13:52:10.727Z
Answers.UserDisplayName: zovits
Answers.Body: <p>In EV3 the pseudocode looks like:</p>
  
  <p><a href="https://i.sstatic.net/3D56x.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/3D56x.png" alt="MindS1&#39;s idea implemented in EV3."></a></p>
  
  <p>Always surprises me how complex it is to represent simple ideas.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-10T00:34:22.320Z
Answers.LastActivityDate: 2019-01-10T00:34:22.320Z
Answers.UserDisplayName: dfrevert
Body: <p>How to program EV3 to wait for a sensor activation for at most X seconds?
  If the sensor is activated in the given time, begin sequence B. If it is not activated in X seconds, begin sequence A.</p>
  
  <p>Explanation:
  My robot arrives at point X, then it waits for the ultrasonic sensor activation (if a hand arrives near the sensor - &lt; 7 cm), but must wait only for 10 seconds.
  If nothing triggers the ultrasonic sensor within 10 seconds the robot must continue with sequence A.
  If, for example, a hand is placed in front of the ultrasonic sensor (&lt;7CM) within 10 seconds the robot must continue with sequence B. Then when sequence B is terminated, the robot should continue with sequence A.</p>
  
  <p>I have tried using loops, switches and asking Gandalf for help but with no success.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-01-02T13:43:52.173Z
Comments.Text: Hi @Zerop! I'll try to edit your question to make it a bit better readable, but I have no idea what you could mean by "Gandalf". Could you please clarify your intent? Thanks!
Comments.UserDisplayName: zovits
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-01-02T14:07:54.887Z
Comments.Text: Hi !! sorry was only a joke. Solution is hard to find and i wrote that i have ask help else to Gandalf (lord of rings) hoping in help !!
Comments.UserDisplayName: Zerop
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-01-02T14:28:10.430Z
Comments.Text: Okay, then I'll leave the reference intact :)
Comments.UserDisplayName: zovits
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-01-03T19:54:41.387Z
Comments.Text: Similar question: https://bricks.stackexchange.com/q/7822/3498
Comments.UserDisplayName: David Lechner
Tags: <ev3><programming>
Title: EV3 Multiple conditions: wait sensor activation for N seconds or
UserDisplayName: Zerop
ThreadText: # EV3 Multiple conditions: wait sensor activation for N seconds or
  
  (Asked by: username_0 on 2019-01-02)
  
  How to program EV3 to wait for a sensor activation for at most X seconds?
  If the sensor is activated in the given time, begin sequence B. If it is not activated in X seconds, begin sequence A.
  
  Explanation:
  My robot arrives at point X, then it waits for the ultrasonic sensor activation (if a hand arrives near the sensor - < 7 cm), but must wait only for 10 seconds.
  If nothing triggers the ultrasonic sensor within 10 seconds the robot must continue with sequence A.
  If, for example, a hand is placed in front of the ultrasonic sensor (<7CM) within 10 seconds the robot must continue with sequence B. Then when sequence B is terminated, the robot should continue with sequence A.
  
  I have tried using loops, switches and asking Gandalf for help but with no success.
  
  **Tags:** ev3, programming
  
  > **Comments:**
  > **username_1**: Hi @username_0! I'll try to edit your question to make it a bit better readable, but I have no idea what you could mean by "Gandalf". Could you please clarify your intent? Thanks!  
  > **username_0**: Hi !! sorry was only a joke. Solution is hard to find and i wrote that i have ask help else to Gandalf (lord of rings) hoping in help !!  
  > **username_1**: Okay, then I'll leave the reference intact :)  
  > **username_2**: Similar question: https://bricks.stackexchange.com/q/7822/3498  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_3 on 2019-01-02. Score: 2 | Accepted answer
  
  Here's some pseudocode that does what you need:
  
  ```
  Reset timer
  Loop block:
      Sensor block, output logical TRUE when condition is reached
      Timer block, output logical TRUE when X seconds have passed
      Logic block, outputs logical TRUE if sensor OR timer is true
  End loop when it receives TRUE from the Logic block.
  Switch block:
      if sensor = condition, SEQUENCE B
  End switch
  SEQUENCE A
  
  ```
  
  The sensor and timer blocks' logical data wires are connected to the logic block. The logic block is set to "OR", which ends the loop if either one is true. Then you use a switch to decide whether or not to execute SEQUENCE B, and after that, SEQUENCE A happens regardless.
  
  > **Comments:**
  > **username_0**: Thanks for help !! I'll try tonight your solution ! thanks to all  
  > **username_3**: @username_0 No problem! Just to elaborate a bit, the key here is that you're using a loop (instead of a wait block) to wait until either logic signal is true. Then after the loop, you use a switch to act based on which condition ended the loop. You could easily extend this to more than 2 conditions, or use it to wait until BOTH conditions are true, etc. Just a cool programming trick to keep in mind for the future.  
  > **username_0**: username_3 thanks a lot !!!!! it's worked perfectly !!!!  I had almost arrived near it. What was wrong was the switch block. I used the switch block waiting for a true logical condition instead of waiting for the sensor. Now it works perfectly. Thank you so much for the invaluable help !!  
  
  ---
  
  ### Answer by username_1 on 2019-01-02. Score: 0
  
  One way would be to use a loop with a counter and a built-in waiting period. In each iteration check the sensor readings: if the value indicates the presence of a hand, exit the loop and start sequence B. Otherwise increment a counter and wait for some time. Finally, if the value of the counter indicates that the 10 seconds have passed, execute sequence A.
  
  
  ---
  
  ### Answer by username_4 on 2019-01-10. Score: 0
  
  In EV3 the pseudocode looks like:
  
  [![username_3's idea implemented in EV3.](https://i.sstatic.net/3D56x.png)](https://i.sstatic.net/3D56x.png)
  
  Always surprises me how complex it is to represent simple ideas.
  
  
  ---
  
  