Project tutorial
Arduino Audiometric Device

Arduino Audiometric Device © GPL3+

This is a cool way to measure your hearing. Hope you enjoy it!

  • 2,815 views
  • 0 comments
  • 5 respects

Components and supplies

Unicorn HAT
×1
Ard nano
Arduino Nano R3
×1
Bourns pec11r 4215f s0024 image 75px
Rotary Encoder with Push-Button
×1
Push Button normally open
×1
12ac6813 40
Knob, Flatted Shaft
×1
Femail Jack
×1
Disused Ear Phones
×1
OLED Display 128x32
×1
3777314
Plastic Enclosure, Junction Box
×1

Necessary tools and machines

About this project

I had a medical test and the doctor measured my hearing. When I left the medical center I said to myself.... I have to build one with Arduino :-)

To make it work, you need to plug the headset in your left year and then start increasing the volume until you hear a sound. When you hear the sound, you need to press the knob that will allow you to check on the next frequency. The display will give you all the info required.

After checking the left ear, you will need to check the right one.

The red color represents the left ear, while the blue color represents the right one!

At the end of the process, you will see a graphical view of both ears. This will tell you the quality of you hearing at each frequency.

Be Aware, that this is not a professional device! And must be used only for fun purpose!

The reset button will allow you to start a new measure again.

Code

Audiometric Testing DeviceArduino
It's a device used to test your hearing
#include <Volume.h>
#include <RotaryEncoder.h>
#include <Adafruit_NeoPixel.h>
#include <OneButton.h>
#include <U8glib.h>

#define PIN 8
Adafruit_NeoPixel strip = Adafruit_NeoPixel(64, PIN, NEO_GRB + NEO_KHZ800);
U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE);  // I2C / TWI 

Volume vol;
// Change these two numbers to the pins connected to your encoder.
//   Best Performance: both pins have interrupt capability
//   Good Performance: only the first pin has interrupt capability
//   Low Performance:  neither pin has interrupt capability

// ----- Rotary settings here ----
#define ROTARYSTEPS 1
#define ROTARYMIN 1
#define ROTARYMAX 8
int lastPos = 0;
int exitFlag = 0;
// Setup a RoraryEncoder for pins A2 and A3:
 RotaryEncoder encoder(A2, A3);

// Last known rotary position.
// Setup a new OneButton on pin A1.  
OneButton button(A1, true);

int risultati[3][8];
int j=0;
int x=0;
int y=0;
int orecchio=1;
int pos = 1;
char db[9][10]=
{ "0 db",
  "10 db",
  "20 db",
  "30 db",
  "40 db",
  "50 db",
  "60 db",
  "70 db",
  "80 db" 
};
char freq[8][10]
{ "125 Hz",
  "250 Hz",
  "500 Hz",
  "1000 Hz",
  "2000 Hz",
  "3000 Hz",
  "4000 Hz",
  "8000 Hz"  
};

int freqn[8][2]
{
  125, 250, 500, 1000, 2000, 3000, 4000, 8000
};

char ear[3][11]
{ "Volume:",
  "Vol Left:",
  "Vol Righ:" 
};




void setup() {
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'

  encoder.setPosition(0 / ROTARYSTEPS); // start with the value of 0.

  u8g.setColorIndex(1);         // pixel on for Display 

  button.attachLongPressStop(longPressStop);


  vol.begin(); // After calling this, delay() and delayMicroseconds will no longer work
               // correctly! Instead, use vol.delay() and vol.delayMicroseconds() for
               // the correct timing

  vol.setMasterVolume(3.00); // Self-explanatory enough, right? Try lowering this value if the speaker is too loud! (0.00 - 1.00)
  vol.delay(500);
    
  Serial.begin(115200);
  Serial.println("Volume test with Encoder:");

}


void loop() {

  button.tick();

  encoder.tick();

  int newPos = encoder.getPosition();
  if (pos != newPos) {

    if (newPos < ROTARYMIN) {
    encoder.setPosition(ROTARYMIN / ROTARYSTEPS);
    newPos = ROTARYMIN;
    } else if (newPos > ROTARYMAX) {
      encoder.setPosition(ROTARYMAX / ROTARYSTEPS);
      newPos = ROTARYMAX;
    } 

    Serial.print(newPos);
    Serial.print(", ");
    Serial.print(x);
    Serial.println();

    if (orecchio < 3){
    u8g.firstPage();  
    do {
      draw(ear[orecchio], 0, 12);
      draw("Freq:", 0, 30);
      draw(db[newPos], 80, 12);
      draw(freq[x], 50, 30);
    } while( u8g.nextPage() );
    } else {
      u8g.firstPage();  
    do {
      draw("  FINAL GRAPH  ", 0, 12);
      draw("   EXECUTED    ", 0, 32);
    } while( u8g.nextPage() );
    }
    
    pos = newPos;
    vol.tone (freqn[x],pos);

    if (orecchio < 3)
      for (j=(x*8); j<64;j++) 
        strip.setPixelColor(j, 0, 0, 0);
    strip.show();

    if ((x==0 or x==2 or x==4 or x==6) and orecchio==1)
      strip.setPixelColor((pos-1)+(x*8), 10, 0, 0);
    if ((x==1 or x==3 or x==5 or x==7) and orecchio==1)
      strip.setPixelColor(((x+1)*8)-(pos), 10, 0, 0);
    if ((x==0 or x==2 or x==4 or x==6) and orecchio==2)
      strip.setPixelColor((pos-1)+(x*8), 0, 0, 10);
    if ((x==1 or x==3 or x==5 or x==7) and orecchio==2)
      strip.setPixelColor(((x+1)*8)-(pos), 0, 0, 10);
    strip.show();
    }

//  vol.delay(10); // solo per test

}



// This function will be called once, when the button1 is released after beeing pressed for a long time.
void longPressStop() {
  Serial.print("Button 1 longPress stop, x=");
//  scanf("%d", &risultati[orecchio][pos]);
  risultati[orecchio][x]=pos;
  x=x+1;
  pos=0;
  encoder.setPosition(1);
  if (x>7 and orecchio == 1) {
    x=0;
    orecchio =2;
    }
    if (x>7 and orecchio == 2) {
    u8g.firstPage();  
    do  {
      draw(" PLEASE WAIT  ", 0, 12);
      draw(" FINAL GRAPH  ", 0, 32);
        } while( u8g.nextPage() );
      strip.clear();
      for (j=1; j<3;j++) {
        Serial.println();
        for (x=0; x<8;x++) {
          if ((x==0 or x==2 or x==4 or x==6) and j==1)
            strip.setPixelColor((risultati[j][x]-1)+(x*8), 10, 0, 0);
          if ((x==1 or x==3 or x==5 or x==7) and j==1)
            strip.setPixelColor(((x+1)*8)-(risultati[j][x]), 10, 0, 0);
          if ((x==0 or x==2 or x==4 or x==6) and j==2)
            if (strip.getPixelColor((risultati[j][x]-1)+(x*8)) == 0)
              strip.setPixelColor((risultati[j][x]-1)+(x*8), 0, 0, 10);
            else
              strip.setPixelColor((risultati[j][x]-1)+(x*8), 10, 0, 10);
          if ((x==1 or x==3 or x==5 or x==7) and j==2)
            if (strip.getPixelColor(((x+1)*8)-(risultati[j][x])) == 0)
              strip.setPixelColor(((x+1)*8)-(risultati[j][x]), 0, 0, 10);
            else
              strip.setPixelColor(((x+1)*8)-(risultati[j][x]), 10, 0, 10);
          strip.show();
          Serial.print(risultati[j][x]);
          Serial.print(", ");
          vol.delay(1000);
        }
        
      }
      x=0;
      orecchio = 3;
    }
 
  Serial.println(x);
  Serial.print("Ear = ");
  Serial.println(orecchio);
  
} // longPressStop1

void draw(char* parola, int posx, int posy) {
  // graphic commands to redraw the complete screen should be placed here  
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr( posx, posy, parola);
}

Schematics

Arduino Audiometric Device
It'a a device that can be used to test your hearing
Audiometric device bb zsng9wjevw

Comments

Similar projects you might like

Stop Smoking Device

Project tutorial by Marc Uberstein

  • 7,388 views
  • 0 comments
  • 14 respects

Portable Thermometer with Android Device

Project tutorial by SekolahRobot

  • 11,023 views
  • 6 comments
  • 31 respects

Automatic Device Tester with Arduino

Project tutorial by Brian Lough

  • 9,968 views
  • 13 comments
  • 39 respects

DIY Ultraviolet Sterilization Device (UVClean)

Project showcase by Henry Mayne

  • 7,536 views
  • 2 comments
  • 19 respects

DIY Simple Weather Forecast Device

Project tutorial by Mirko Pavleski

  • 5,052 views
  • 2 comments
  • 8 respects

How to Make Arduino Social Distancing Device with PIR

Project tutorial by DKARDU

  • 4,719 views
  • 0 comments
  • 4 respects
Add projectSign up / Login