Devices & Components
Arduino Uno Rev3
Jumper wires (generic)
5 mm LED: Red
Resistor 330 ohm
DAOKI High Sensitivity Sound Microphone Sensor Detection Module For Arduino AVR PIC
USB-A to B Cable
Hardware & Tools
Breadboard, 830 Tie Points
Extraction Tool, 6 Piece Screw Extractor & Screwdriver Set
Software & Tools
Arduino IDE
Project description
Code
SoundDirectionFinder
arduino
This code/sketch makes finding the general direction of sound easy. This code/sketch drives to LEDs to indicate which of two microphones is receiving an audible sound. If both microphone sensors detect sound both (left and right) LEDs light indicating that both microphones have detected sound. If one microphone sensor (left or right) detects sound, then the corresponding LED (left or right) will light up. If both microphone sensors detect sound then both LEDs will light up.
1/* 2 File/Sketch Name: SoundDirectionFinder 3 4 Version No.: v1.0 Created 14 August, 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 drives to LEDs to indicate which of two microphones is receiving an audible sound. 9 If both microphone sensors detect sound both (left and right) LEDs light indicating that both microphones have detected sound. If one microphone sensor (left or right) detects sound, 10 then the corresponding LED (left or right) will light up. If both microphone sensors detect sound then both LEDs will light up. 11 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/08/15/my-weekend-project-sound-direction-tester/ 18 19 */ 20 21int leftLedPin=13; 22int rightLedPin=12; 23int rightSensorPin=7; 24int leftSensorPin=8; 25boolean rightVal = 0; 26boolean leftVal = 0; 27 28void setup() 29{ 30 pinMode(leftLedPin, OUTPUT); 31 pinMode(rightLedPin, OUTPUT); 32 pinMode(leftSensorPin, INPUT); 33 pinMode(rightSensorPin, INPUT); 34 Serial.begin (9600); 35} 36 37void loop () 38{ 39 rightVal =digitalRead(rightSensorPin); 40 leftVal =digitalRead(leftSensorPin); 41 42 // when the sensor detects a signal above the threshold value, LED flashes 43 if (leftVal==LOW && rightVal==LOW) 44 { 45 digitalWrite(leftLedPin, LOW); 46 digitalWrite(rightLedPin, LOW); 47 Serial.println("None"); 48 } 49 else if (leftVal==LOW && rightVal==HIGH) 50 { 51 digitalWrite(leftLedPin, LOW); 52 digitalWrite(rightLedPin, HIGH); 53 Serial.println("Right"); 54 } 55 else if (leftVal==HIGH && rightVal==LOW) 56 { 57 digitalWrite(leftLedPin, HIGH); 58 digitalWrite(rightLedPin, LOW); 59 Serial.println("Left"); 60 } 61 else 62 { 63 digitalWrite(leftLedPin, HIGH); 64 digitalWrite(rightLedPin, HIGH); 65 Serial.println("Both"); 66 } 67} 68 69
Downloadable files
Fritzing Diagram
Fritzing Diagram
Fritzing Diagram

Fritzing Diagram
Fritzing Diagram
Fritzing Diagram

Comments
Only logged in users can leave comments