Giter Site home page Giter Site logo

bidule21 / arduino-sound-localization Goto Github PK

View Code? Open in Web Editor NEW

This project forked from danielgusland/arduino-sound-localization

0.0 1.0 0.0 1.26 MB

A repository containing the source code and description for the project presented in https://www.youtube.com/watch?v=vGGvgp6u1-M

C++ 100.00%

arduino-sound-localization's Introduction

Arduino-sound-localization

A repository containing the source code and description for the project presented in https://www.youtube.com/watch?v=vGGvgp6u1-M. The source code has been "hidden" in the comment section for quite a while and i am sorry for those of you who might have missed it.

The project was a part of a small subject during my bachelors degree and was done together with Jonas Waaler. It has been quite some time since I have looked at it. Unfortunately the report is written in Norwegian, but some quick translation of the variables can be found in the code. I have made a small descrition of how the code works below. There is also heaps and loads of improvements that can be done.

Description

Each axis is controlled by a separate arduino and the program itself is really simple. The peaking output of the microphones are connected to pin4 and pin5. Basically the program checks if either pin4 or pin5 is high and then records the time until the other is high as well. This is done using low-level functions to achieve a relatively high sampling rate.

The sampling of the time delay is done in this function:

 //HVIS LOGISK OG PIN 5 OG PIND, NOTER TID
   if((PIND & B00100000)!=0)
   {
     tid1 = micros();
     //VENT TIL PIN 4 MOTTAR SIGNAL
     while((PIND & B00010000)==0)
     {}
     //NOTER TID TIL PIN 4
     tid2 = micros();
   
   //REGNER UT TIDSDIFFERANSE
   tid3 = tid2-tid1;

When the time "tid3" is recorded, which is the time delay for the signal to pass from one microphone to the other, the angle corresponding to this time delay is calculated using:

#define AVSTAND 0.145
float regn_ut_radianer (float time)
//REGNER UT HVOR LYDEN KOMMER FRA
//RETURNERER SVARET I RADIANER
  {
    return (asin((time*0.000001*343.00)/(AVSTAND)));
  }

When this angle is calculated, it is converted to degrees and the steppers are steered towards the sound source. All of the above is done in the following lines:

 //REGN UT VINKEL OG GJØR DET OM FRA RADIANER TIL GRADER OG SEND TIL STYR_STEP FUNKSJON
 radianer = regn_ut_radianer(tid3);
 grader = fra_rad_til_grad(radianer);
 delay(20);
 styr_step(int(grader));

arduino-sound-localization's People

Contributors

jonasswa avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.