Manufacturers

RSS feed

No RSS feed added

Linkerkit Sound Sensor

This is a simple sound sensor using a microphone, and an op-amp to set a signal high when a pre-determined level of sound is sensed. The level is adjusted using a small trim pot on the sensor board. There is an example Arduino sketch along with an example C/C++ code for the pcDuino below in more info.

More details


AU$6.95

LKT-00210

4 items in stock

Add to my wishlist

Loyalty program By buying this product you can collect up to 6 loyalty points. Your cart will total 6 points that can be converted into a voucher of AU$0.12.


100 quantities 75 quantities 50 quantities 25 quantities 10 quantities 5 quantities
-AU$1.39 -AU$1.22 -AU$1.04 -AU$0.87 -AU$0.69 -AU$0.35

Customers who bought this product also bought...

// Public domain sketch
// This sketch monitors the Linker Sound Sensor
// and turns on an LED when the sound level is
// greater than that set by the sensor's pot.

const int SoundSensorPin=7;
const int LEDPin=8;

void setup()
{
  pinMode(SoundSensorPin, INPUT);
  pinMode(LEDPin, OUTPUT);
  digitalWrite(LEDPin,0);
  Serial.begin(57600);   // init serial to 9600b/s
}  

void loop()
{
  // You should adjust the pot on the sensor board to change
  // at what level of sound the LDED lights
  int sensorValue = digitalRead(SoundSensorPin);
  if(sensorValue==1)
  {
    Serial.println("Hign");
    digitalWrite(LEDPin,1);
    delay(250);
  }
  else
  {
    Serial.println("Low");
    digitalWrite(LEDPin,0);  
    }
}

 

Example pcDuino C/C++ code to take input from sensor and turn on LED

// Connect sensor to pin 2 and an LED to pin 3. Activate sensor and LED
// lights for 2 seconds and turns off.

#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

// some defines which you can put into a .h file
#define GPIO_MODE_PATH "/sys/devices/virtual/misc/gpio/mode/"
#define GPIO_PIN_PATH "/sys/devices/virtual/misc/gpio/pin/"
#define GPIO_FILENAME "gpio"
#define HIGH '1'
#define LOW  '0'
#define INPUT  '0'
#define OUTPUT '1'
#define INPUT_PU '8'

// There are 18 IO pins, so declare file descriptors for all 18
int pinMode[18];
int pinData[18];

void writePin(int fileID, int value);

int main(void)
{
        char inputBuf = HIGH;
        char path[256];

        // Initialise the file descriptors for pin 2 & 3 mode and data files
        for (int i = 2; i <= 3; i++)
        {
                memset(path,0,sizeof(path)); // clear the path variable
                // Create path for pin mode file
                sprintf(path, "%s%s%d", GPIO_MODE_PATH, GPIO_FILENAME, i);
                pinMode[i] = open(path, O_RDWR);  // set pin mode
                memset(path, 0, sizeof(path)); // clear the path variable
                // Create path for the pin data file
                sprintf(path, "%s%s%d", GPIO_PIN_PATH, GPIO_FILENAME, i);
                pinData[i] = open(path, O_RDWR); // set pin data
        }

        writePin(pinMode[3], OUTPUT); // set as output
        writePin(pinData[3], LOW); // and write a LOW (0) to pin
        writePin(pinMode[2], INPUT_PU); // set pin 2 as input

        // Lets wait for pin 2 to go high (switch pressed)
        do
        {
                lseek(pinData[2], 0, SEEK_SET); // set to begining of file
                // first byte is the interesting one so read it
                read(pinData[2], &inputBuf, 1);
                usleep(100000); // 0.1sec sleep
        } while (inputBuf == HIGH);
        // set pin 3 high for 2 seconds then low again
        writePin(pinData[3], HIGH);
        usleep(2000000);
        // now turn pin 3 off (LOW)
        writePin(pinData[3], LOW);
        usleep(2000000);
}


void writePin(int fileID, int value)
{
  char buf[4];  // Need to write 4 bytes for it to work.
  memset((void *)buf, 0, sizeof(buf)); // clear the buffer out.
  sprintf(buf, "%c", value);  // create buffer to write
  lseek(fileID, 0, SEEK_SET);   // set to top of the file
  write(fileID, buf, sizeof(buf));  // and write.
}

No customer comments for the moment.

Only registered users can post a new comment.

Cart  

No products

Shipping AU$0.00
Total AU$0.00

Check out