5

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, how do I 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 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.

  • 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? – Ambo100 Dec 20 '17 at 12:23
  • @Ambo100 i have edited my question please have a look – user3667576 Dec 20 '17 at 12:56
  • Thank you. I'm still trying to visualise what it is you're trying to achieve. Is this diagram accurate? 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? – Ambo100 Dec 20 '17 at 16:22
  • What kind of motor do you have available? Servo? Stepper? – Mast Dec 20 '17 at 21:32
  • the motor is standard motor provided with ev3 kit it is servo motor – user3667576 Dec 21 '17 at 8:17
2

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
}

TO detect the highest you can use this:

  • 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.. – user3667576 Jan 10 '18 at 16:40
  • @user3667576 Can you share the EV3 code snippet for that? I'd find it very useful! – Sam Bridgham Apr 4 '18 at 3:11
0

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.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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