Home Code Arduino esplora sound level indicator

Arduino esplora sound level indicator

by shedboy71

In this example we use an Arduino Esplora nad use the on board micropone and RGB led and create a sound level project, if the sound level is an acceptable level then the RGB led will be green, if the value exceeds this level we will change the RGB led to red.

esplora

esplora

 

Code

This example uses some of the built in esplora functions, namely the readMicrophone and writeRGB ones

[codesyntax lang=”cpp”]

#include <Esplora.h>

void setup()
{
  Serial.begin(9600);
} 

void loop()
{
  int value = Esplora.readMicrophone();
  Esplora.writeRGB(0, 0, 0);
  Serial.println(value);
  if(value < 100)
  {
      Esplora.writeRGB(0, 255, 0);
      delay(100);
  }
  else
  {
      Esplora.writeRGB(255, 0, 0);
      delay(100);
  }
  delay(100);
}

[/codesyntax]

Share

You may also like