| 
    upm
    0.3.2
    
   Sensor/Actuator repository for libmraa (v0.7.2) 
   | 
 
API for the Buzzer component. More...
This file defines the Buzzer interface for libbuzzer. This sensor can make different tones when connected to a pin capable of analog pulse-width modulation. It emits sound using a piezoelectric material that vibrates at different frequencies based on the input voltage.
Public Member Functions | |
| Buzzer (int pinNumber) | |
| ~Buzzer () | |
| int | playSound (int note, int delay) | 
| void | stopSound () | 
| void | setVolume (float vol) | 
| float | getVolume () | 
| std::string | name () | 
Protected Attributes | |
| std::string | m_name | 
| Buzzer | ( | int | pinNumber | ) | 
| int playSound | ( | int | note, | 
| int | delay | ||
| ) | 
Plays a tone for a certain amount of time or indefinitely. When delay is not used, the sound can be stopped by calling stopSound().
| note | Note to play (C, D, E, etc.) or frequency | 
| delay | Time in microseconds for which to play the sound; if the value is 0, the sound is played indefinitely | 

| void stopSound | ( | ) | 
Stops the sound currently playing. Should be called when playSound() does not have a delay value.

| void setVolume | ( | float | vol | ) | 
Sets the volume for the buzzer, but may affect the sound timbre. Works best with halved values; e.g., 1.0, 0.5, 0.25, etc.
| vol | Value to set the volume to, from 0.0 to 1.0 | 

| float getVolume | ( | ) | 
Gets the buzzer volume.
      
  | 
  inline | 
Returns the name of the sensor.
 1.8.9.1