Giter VIP home page Giter VIP logo

easybuzzer's Introduction

EasyBuzzer

License

A library to easily make beeps with a Buzzer.

Recent changes: Added support for Arduino Platform.

Fixes and new features as well as support for more platforms will be included in further releases.

Supported Platforms

Currently supports the Esp32 and Arduino platforms.

Support for these others platforms will be added Particle Photon Particle Electron

Getting Started

Include the library in the sketch

#include <EasyBuzzer.h>

Set the pin where the buzzer is connected

By default, the library is configured to use the pin number 4. You may change the default pin number, modifying the value of DEFAULT_PIN in Config.h file. To set the pin number on the sketch, call the function EasyBuzzer.setPin(pin) on the setup.

int pin = 2;
void setup() {
  EasyBuzzer.setPin(pin);
};  

Run the library

void loop() {
  /* Always call this function in the loop for EasyBuzzer to work. */
  EasyBuzzer.update();
};

Uses

Regular Beep

Beep continuously at a given frequency.

/* Beep continuously at a given frequency. */
EasyBuzzer.beep(
  frequency	// Frequency in Hertz(HZ).
);

Beep at a given frequency an specific number of times.

/* 
	Beep at a given frequency an specific number of times. 
	The default onDuration and offDuration is set in Config.h file. 
*/
EasyBuzzer.beep(
  frequency,	// Frequency in Hertz(HZ).
  beeps		// The number of beeps.
);

Beep at a given frequency an specific number of times, with callback functionality.

/* 
	Beep at a given frequency an specific number of times, with callback functionality. 
	The default onDuration and offDuration is set in Config.h file.
*/
EasyBuzzer.beep(
  frequency,	// Frequency in Hertz(HZ).
  beeps,	// The number of beeps.
  callback	// [Optional] Function to call when done.
);

Beep Sequence

Create a sequence of beeps at a given frequency.

/* Create a sequence of beeps at a given frequency. */
EasyBuzzer.beep(
  frequency,		// Frequency in hertz(HZ).
  onDuration, 		// On Duration in milliseconds(ms).
  offDuration, 		// Off Duration in milliseconds(ms).
  beeps, 		// The number of beeps per cycle.
  pauseDuration, 	// Pause duration.
  cycles, 		// The number of cycle.
  callback		// [Optional] Function to call when done.
);	

Single Beep For A Duration

Single beep at a given frequency, for an specific duration.

/* Single beep. */
EasyBuzzer.singleBeep(
  frequency,	// Frequency in hertz(HZ).
  duration	// Duration of the beep in milliseconds(ms).
);

Single beep at a given frequency, for an specific duration, with callback functionality.

/* Single beep at a given frequency, for an specific duration, with callback functionality. */
EasyBuzzer.singleBeep(
  frequency, 	// Frequency in hertz(HZ).
  duration, 	// Duration of the beep in milliseconds(ms).
  callback	// [Optional] Function to call when done.
);

Stop Beeping

Use this function to stop the beeping. You may call this function at all time, everywhere in the code.

EasyBuzzer.stopBeep();

Modifying the default duration values

The default duration values are defined in the Config.h file. You may change those values on the Config.h file or use the provided function to change them.

EasyBuzzer.setOnDuration(duration);	// Set On duration.
EasyBuzzer.setOffDuration(duration);	// Set Off duration.
EasyBuzzer.setPauseDuration(duration);	// Set Pause duration.

Copyright

MIT © Evert Arias

easybuzzer's People

Contributors

evert-arias avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.