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, 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.

8
  • 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, 2017 at 12:23
  • @Ambo100 i have edited my question please have a look Dec 20, 2017 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, 2017 at 16:22
  • What kind of motor do you have available? Servo? Stepper?
    – Mast
    Dec 20, 2017 at 21:32
  • the motor is standard motor provided with ev3 kit it is servo motor Dec 21, 2017 at 8:17

2 Answers 2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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