Skip to content

This library provides a 2-source non-block volume control for DFPlayer mini mp3 module.

License

Notifications You must be signed in to change notification settings

bscheshir/volume-control

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VolumeControl

This library provides a 2-source non-block volume control for DFPlayer mini mp3 module.

Usage

Download ZIP; open Sketch menu and then Include Library -> Manage Libraries -> Add .ZIP Library;
Sketch -> Include Library -> Manage Libraries -> VolumeControl

Libraries guide

#include <VolumeControl.h>

You must declare function with your own setter

void setVolume(int volume)

and pass it to constructor as link.
This function will be called if volume is changed.

In main loop() call void update(unsigned long currentMillis) to check changes and update volume (each timeInterval mills)

See example below.

Использование

Загрузите ZIP, после чего добавьте через меню Скетч -> Подключить библиотеку -> Добавить ZIP библиотеку;
Скетч -> Подключить библиотеку -> VolumeControl

#include <VolumeControl.h>

Объявите функцию регулировки громкости

void setVolume(int volume)

и передайте её в конструктор по ссылке.
При изменении громкости эта функция будет вызвана.

В цикле loop() вызывайте void update(unsigned long currentMillis) для проверки изменений громкости (каждые timeInterval) и установки громкости

Example / Пример

#include <VolumeControl.h>

#define VOL A0

void setVolume(int volume) {
  Serial.println((String)"Volume set to " + volume);
  mp3_set_volume(volume);
}

VolumeControl vc(VOL, 500, &setVolume);

...
void setup() {
...
}

...
void loop() {
  vc.update(millis());
  ...
}

About

This library provides a 2-source non-block volume control for DFPlayer mini mp3 module.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages