Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO and KY-038 Sound Sensor Controlled LED

View and Edit Project In Cirkit DesignerImage of Arduino UNO and KY-038 Sound Sensor Controlled LED

Circuit Documentation

Summary

This circuit consists of a KY-038 sound sensor module, an Arduino UNO microcontroller, and a red LED. The purpose of the circuit is to detect loud noises using the KY-038 sound sensor and then light up the LED for a short duration when a loud noise is detected.

Component List

  1. KY-038 Sound Sensor Module

    • Pins: +, G, A0, D0
    • Description: The KY-038 is a sound sensor module that detects sound levels and outputs a digital signal when a certain threshold is reached.
  2. Arduino UNO

    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
    • Description: The Arduino UNO is a microcontroller board based on the ATmega328P. It has 14 digital input/output pins, 6 analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP header, and a reset button.
  3. LED: Two Pin (red)

    • Pins: cathode, anode
    • Description: A standard red LED with two pins: anode (positive) and cathode (negative).

Wiring Details

KY-038 Sound Sensor Module

Arduino UNO

LED: Two Pin (red)

Code Documentation

Code for Arduino UNO

int sensor = 2; // Connected to digital output of KY-038 sound sensor module
int pwr = 13; // Connected to positive of LED
boolean is_on = false; // To determine/track if LED is on or off

void setup() {
  pinMode(sensor, INPUT); // Setting the pin to input for reading data
  pinMode(pwr, OUTPUT); // Setting the pin to output for turning the LED on/off
}

void loop() {
  int data = digitalRead(sensor); // Reading data from sensor and storing in variable

  if (data == 1) { // 1 is sent from sensor when loud noise is detected
    digitalWrite(pwr, HIGH);
    delay(500);
    digitalWrite(pwr, LOW);
  }
}

This code initializes the sensor pin (D2) as an input and the LED pin (D13) as an output. In the main loop, it reads the digital signal from the KY-038 sound sensor. If a loud noise is detected (indicated by a digital high signal), the LED is turned on for 500 milliseconds and then turned off.