Micro:bit micropython library to calibrate a sound sensor KY038
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
sample
.gitattributes
.gitignore
README.rst
ky038.py

README.rst

micropython library to calibrate and use a sound sensor KY038

This library helps calibrating a sound sensor KY038 with the micro:bit. It also provides a clap counter functionality. It assumes the Digital output of the sound sensor is connected to pin0 of the micro:bit. It uses an analog input, since the digital input seems not to be very reliable powering the sensor with 3V. Power and ground of the sensor are also connected to the micro:bit.

1   Main features

  • Helps calibrate the sound sensor showing an arrow on the micro:bit indicating the direction to turn the potentiometer
  • Has a clap counter included

2   Library usage

2.1   calibrate()

Inititalizes the calibration routine. The micro:bit will display an arrow indicating the direction that you should be turning the potentiometer with a screwdriver.

from ky038 import KY038

KY038.calibrate()

2.2   count_claps()

Count the number of claps or any consecutive sudden sound.

from ky038 import KY038

KY038.calibrate()
while True:
    print(KY038.count_claps())