https://github.com/niklauslee/active-buzzer
Kaluma library to generate beep sound with active buzzer
https://github.com/niklauslee/active-buzzer
buzzer kaluma sound
Last synced: 2 months ago
JSON representation
Kaluma library to generate beep sound with active buzzer
- Host: GitHub
- URL: https://github.com/niklauslee/active-buzzer
- Owner: niklauslee
- License: mit
- Created: 2022-02-17T04:02:12.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-02-17T04:57:09.000Z (over 3 years ago)
- Last Synced: 2025-01-21T17:30:47.833Z (4 months ago)
- Topics: buzzer, kaluma, sound
- Language: JavaScript
- Homepage:
- Size: 58.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Active Buzzer
Kaluma library to generate beep sound with active buzzer
# Wiring
Here is a wiring example.
| Raspberry Pi Pico | Active Buzzer |
| ----------------- | ------------- |
| GND | - |
| GP0 | + |Wiring for a board with TR (KY-012).
| Raspberry Pi Pico | Active Buzzer |
| ----------------- | ------------- |
| 3V3 | VCC |
| GND | GND |
| GP0 | I/O |
# Install
```sh
npm install https://github.com/niklauslee/active-buzzer
```# Usage
```javascript
const buzzer = require('active-buzzer');
const PIN = 0;// beep 5 times.
buzzer.beep(PIN, 5);
delay(1000);// beep 10 times.
buzzer.beep(PIN, 10);
delay(1000);// beep 5 times with 100ms interval.
buzzer.beep(PIN, 5, 100);
```Example for some boards with TR (reversed signal)
```javascript
// Example for boards with TR (beep = LOW, stop = HIGH)const buzzer = require('active-buzzer');
const PIN = 0;// beep 5 times.
buzzer.beep(PIN, 5, 50, LOW);
delay(1000);// beep 10 times.
buzzer.beep(PIN, 10, 50, LOW);
delay(1000);// beep 5 times with 100ms interval.
buzzer.beep(PIN, 5, 100, LOW);
```# API
## beep(pin, count[, interval[, beepSignal]])
Generate beep sound.
- **`pin`** `` Pin number for active buzzer.
- **`count`** `` Number of count to beep.
- **`interval`** `` delay time in milliseconds to beep as well as stop. Default: `50`.
- **`beepSignal`** `` Signal to make beep sound. Default: `HIGH`. (In some boards with TR, LOW signal is required to make beep bound.)