Answers.Body: <p>To detect the highest sound you can use this code. It would help if you posted a picture of your bot, but with a general idea here you go:</p>
  
  <pre><code>FOREVER loop
  {
  
  if RightSensor &gt; Left Sensor :
      if RightSensor &gt; MidSensor :
          highest = RightSensor
      else :
          highest = MidSensor
  else:
      highest = LeftSensor
  
  if LeftSensor is the highest:
          turn left
  if RightSensor is the highest:
          turn right
  if MidSensor is the highest:
          do not turn
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-10T16:40:51.460Z
Answers.Text: thanks for your answer if it would have been in simple code i myself would have resolved it, i am working with default ide of ev3 which uses blocks not code i have found the solution will post it soon..
Answers.UserDisplayName: user3667576
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-04T03:11:43.200Z
Answers.Text: @user3667576 Can you share the EV3 code snippet for that? I'd find it very useful!
Answers.UserDisplayName: Sam Bridgham
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2017-12-25T16:38:01.083Z
Answers.LastActivityDate: 2020-05-14T18:10:03.467Z
Answers.LastEditDate: 2020-05-14T18:10:03.467Z
Answers.UserDisplayName: Vikhyat Agarwal
Answers.Body: <p>I don't understand the question.  I do understand the quandary of trying to write code in the blocks available in the EV3 IDE.</p>
  
  <p>I suspect the questioner really wants something like, given 3 sound sensors, how can I build and program a motor to point to the loudest sound.  One could imagine a turntable with the brick on the platter and 3 sensors mounted 45 degrees from each other.  Rotate until the middle sensor is loudest.</p>
  
  <p>A part of the solution would be to determine which is loudest. See Vikhyat's psuedocode. This is a snippet to do that.</p>
  
  <p><a href="https://i.sstatic.net/axf6Y.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/axf6Y.png" alt="Determine loudest of 3 sensors continuously, forever."></a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-07T23:02:57.707Z
Answers.LastActivityDate: 2018-04-07T23:02:57.707Z
Answers.UserDisplayName: dfrevert
Body: <p>I have 3 sound sensors and a motor connected to four ports of the same brick.</p>
  
  <p>My motor should rotate by some angle towards the highest sound detected by the sensor, and now I'm wondering how I'm supposed to do the following: write an infinite loop for continuous detection but once true the motor keeps on rotating for the same angle.</p>
  
  <p>Is there some way to rotate for a certain angle, stop and then wait for the next sensor to detect the highest sound and then move again for the same angle and wait again?</p>
  
  <p>I am using EV3 brick with NXT sound sensors and a large motor,
  so far my logic for detecting the highest sound detected by the sensor is working but  I am facing problems controlling the motor.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-12-20T12:23:42.433Z
Comments.Text: I have attempted to re-write the question as best as I can. Which brick are you using, the EV3 or NXT brick and are you using the standard programming interface? What have you tried so far and what works?
Comments.UserDisplayName: Ambo100
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-12-20T12:56:52.423Z
Comments.Text: @Ambo100 i have edited my question please have a look
Comments.UserDisplayName: user3667576
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-12-20T16:22:59.000Z
Comments.Text: Thank you. I'm still trying to visualise what it is you're trying to achieve. Is this [diagram accurate](https://i.imgur.com/snj6aQE.png)? The M representing the motor with the three sensors surrounding it? Are you trying to make the motor rotate to the sound source or towards the sensor that picked up the loudest sound?
Comments.UserDisplayName: Ambo100
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-12-20T21:32:00.300Z
Comments.Text: What kind of motor do you have available? Servo? Stepper?
Comments.UserDisplayName: Mast
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-12-21T08:17:24.693Z
Comments.Text: the motor is standard motor provided with ev3 kit it is servo motor
Comments.UserDisplayName: user3667576
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-12-21T08:25:15.713Z
Comments.Text: @Ambo100 yes the motor should rotate towards the loudest sound picked by sensor, the motor has a pointer which rotates towards the sensor which detects highest sound the senors can be in series and motor on one side, like all sensors on one side of triangle and motor on the opposite vertex.
Comments.UserDisplayName: user3667576
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-05-14T17:17:42.933Z
Comments.Text: "A motor connected to four ports of the same brick" What?? Please be clear since nobody can really give a definitive answer to your question!
Comments.UserDisplayName: mindstormsboi
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-05-14T17:23:15.410Z
Comments.Text: And there are three servo motors included in the kit: two large ones, and one smaller one. By saying "it servo motor" you're not helping us in any way, because you are lacking the most important details, like which one. Just imagine you were sending all this information to a stranger in real life. That should help you.
Comments.UserDisplayName: mindstormsboi
Tags: <ev3><mindstorms><nxt><programming>
Title: How can I program a motor to rotate towards the source of sound?
UserDisplayName: user3667576
ThreadText: # How can I program a motor to rotate towards the source of sound?
  
  (Asked by: username_0 on 2017-12-20)
  
  I have 3 sound sensors and a motor connected to four ports of the same brick.
  
  My motor should rotate by some angle towards the highest sound detected by the sensor, and now I'm wondering how I'm supposed to do the following: write an infinite loop for continuous detection but once true the motor keeps on rotating for the same angle.
  
  Is there some way to rotate for a certain angle, stop and then wait for the next sensor to detect the highest sound and then move again for the same angle and wait again?
  
  I am using EV3 brick with NXT sound sensors and a large motor,
  so far my logic for detecting the highest sound detected by the sensor is working but I am facing problems controlling the motor.
  
  **Tags:** ev3, mindstorms, nxt, programming
  > **Comments:**
  > **username_1**: I have attempted to re-write the question as best as I can. Which brick are you using, the EV3 or NXT brick and are you using the standard programming interface? What have you tried so far and what works?  
  > **username_0**: @Ambo100 i have edited my question please have a look  
  > **username_1**: Thank you. I'm still trying to visualise what it is you're trying to achieve. Is this [diagram accurate](https://i.imgur.com/snj6aQE.png)? The M representing the motor with the three sensors surrounding it? Are you trying to make the motor rotate to the sound source or towards the sensor that picked up the loudest sound?  
  > **username_2**: What kind of motor do you have available? Servo? Stepper?  
  > **username_0**: the motor is standard motor provided with ev3 kit it is servo motor  
  > **username_0**: @Ambo100 yes the motor should rotate towards the loudest sound picked by sensor, the motor has a pointer which rotates towards the sensor which detects highest sound the senors can be in series and motor on one side, like all sensors on one side of triangle and motor on the opposite vertex.  
  > **username_3**: "A motor connected to four ports of the same brick" What?? Please be clear since nobody can really give a definitive answer to your question!  
  > **username_3**: And there are three servo motors included in the kit: two large ones, and one smaller one. By saying "it servo motor" you're not helping us in any way, because you are lacking the most important details, like which one. Just imagine you were sending all this information to a stranger in real life. That should help you.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_4 on 2017-12-25. Score: 2
  
  To detect the highest sound you can use this code. It would help if you posted a picture of your bot, but with a general idea here you go:
  FOREVER loop
  {
  
  if RightSensor > Left Sensor :
      if RightSensor > MidSensor :
          highest = RightSensor
      else :
          highest = MidSensor
  else:
      highest = LeftSensor
  
  if LeftSensor is the highest:
          turn left
  if RightSensor is the highest:
          turn right
  if MidSensor is the highest:
          do not turn
  }
  
  > **Comments:**
  > **username_0**: thanks for your answer if it would have been in simple code i myself would have resolved it, i am working with default ide of ev3 which uses blocks not code i have found the solution will post it soon..  
  > **username_5**: @user3667576 Can you share the EV3 code snippet for that? I'd find it very useful!  
  
  ---
  
  ### Answer by username_6 on 2018-04-07. Score: 1
  
  I don't understand the question. I do understand the quandary of trying to write code in the blocks available in the EV3 IDE.
  
  I suspect the questioner really wants something like, given 3 sound sensors, how can I build and program a motor to point to the loudest sound. One could imagine a turntable with the brick on the platter and 3 sensors mounted 45 degrees from each other. Rotate until the middle sensor is loudest.
  
  A part of the solution would be to determine which is loudest. See Vikhyat's psuedocode. This is a snippet to do that.
  
  [![Determine loudest of 3 sensors continuously, forever.](https://i.sstatic.net/axf6Y.png)](https://i.sstatic.net/axf6Y.png)
  
  
  ---
  
  