In this project, I create a sound location search tool. This circuit can be used as the basic element of a robot that reacts to sound.
Devices and components
Arduino Uno Rev3
Jumper wires (generic)
Full Size Solderless Breadboard
USB-A to B cable
42BYGHM809 Bipolar stepper motor
Angled IC DIP Sockets
A4988 stepper motor driver board
5mm Flange Shaft
DAOKI High Sensitive Sound Microphone Sensor Detection Module for Arduino AVR PIC
Materials and tools
Variable power supply
Extraction Tool, 6 Piece Screw Extractor and Screwdriver Set
Computer
Software and tools
Arduino IDE
Project description
Sound locator
arduino
This code/sketch makes it easy to find the general direction of the sound. This code/sketch is for a sound locator using two microphone sensors.
in conjunction with an Arduino Uno. The code/sketch interrogates two microphone sensors in a sound location finder circuit. If sound is detected in a microphone sensor and not in the
On the other hand, the Arduino requires a stepper motor in the circuit to rotate the sound detection board in the direction of the sound. Whether sound is detected in both microphones or not
a sound is detected, the circuit does nothing and continues to poll the microphone sensors.
1/*
2 File/Sketch Name: SoundLocator
3
4 Version No.: v1.0 Created 8 September, 2019
5
6 Original Author: Clyde A. Lettsome, PhD, PE, MEM
7
8 Description: This code/sketch makes finding the general direction of sound easy. This code/sketch is for a sound location finder using two microphone sensors
9 in conjunction with an Arduino Uno. The code/sketch polls two microphone sensors in a sound location finder circuit. If sound is detected in one microphone sensor and not the
10 other, the Arduino request a stepper motor in the circuit to turn the sound detection board in the direction of the sound. If the sound is detected in both microphones or no
11 sound is detected, the circuit does nothing and continues to poll the microphone sensors.
12
13 License: This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License (GPL) version 3, or any later
14 version of your choice, as published by the Free Software Foundation.
15
16 Notes: Copyright (c) 2019 by C. A. Lettsome Services, LLC
17 For more information visit https://clydelettsome.com/blog/2019/09/08/my-weekend-project-sound-location-finder/
18
19 */
20const int stepsPerRevolution = 400; // change this to fit the number of steps per revolution for your motor
21const int numberOfSteps = stepsPerRevolution/8; //45 degree turns
22const int dirPin=12;
23const int stepPin=13;
24const int rightSensorPin=7;
25const int leftSensorPin=8;
26const int enablePin=5 ;
27boolean rightVal = 0;
28boolean leftVal = 0;
29
30void setup()
31{
32 pinMode(leftSensorPin, INPUT); //Make pin 8 an input pin.
33 pinMode(rightSensorPin, INPUT); //Make pin 7 an input pin.
34 pinMode (stepPin, OUTPUT); //Make pin 13 an output pin.
35 pinMode (dirPin, OUTPUT); //Make pin 12 an output pin.
36 pinMode (enablePin, OUTPUT); //Make pin 5 an output pin.
37
38 digitalWrite(enablePin, LOW); //Enable is active low
39 Serial.begin (9600); // initialize the serial port:
40}
41
42void loop ()
43{
44 //poll inputs for signal
45 rightVal =digitalRead(rightSensorPin);
46 leftVal =digitalRead(leftSensorPin);
47
48 // when the sensor detects a signal above the threshold value set on sensor, turn finder to the direction of sound
49 if (leftVal==LOW && rightVal==HIGH)
50 {
51 Serial.println("Turning Right");
52 digitalWrite(dirPin,LOW); //turn counter-clockwise
53
54 //turn finder in the direction of the sound
55 for(int steps = 0; steps < numberOfSteps; steps++)
56 {
57 //create pulse to turn motor one step at a time
58 digitalWrite(stepPin,HIGH);
59 delayMicroseconds(10000);
60 digitalWrite(stepPin, LOW);
61 delayMicroseconds(10000);
62 }
63 delayMicroseconds(100000);
64 rightVal = 0;
65 leftVal = 0;
66 }
67 else if (leftVal==HIGH && rightVal==LOW)
68 {
69 Serial.println("Turning Left");
70 digitalWrite(dirPin,HIGH); //turn clockwise
71
72 //turn finder in the direction of the sound
73 for(int steps = 0; steps < numberOfSteps; steps++)
74 {
75 //create pulse to turn motor one step at a time
76 digitalWrite(stepPin,HIGH);
77 delayMicroseconds(10000);
78 digitalWrite(stepPin, LOW);
79 delayMicroseconds(10000);
80 }
81 delayMicroseconds(100000);
82 rightVal = 0;
83 leftVal = 0;
84 }
85 else
86 {
87 //Do nothing
88 rightVal = 0;
89 leftVal = 0;
90 }
91}
92
93
Downloadable files
Fritzing diagram
Fritzing diagram
Fritzing diagram
Fritzing diagram
Note: Content and images are from: https://projecthub.arduino.cc/, with some modifications.
If you want it removed due to copyright reasons, please leave a comment. Thank you.
I want to share this article more widely so that everyone knows about Arduino and your project.