upm  0.1.8
Sensor/Actuator repository for libmraa (v0.4.5)
 All Data Structures Files Functions Variables Macros Pages
Public Member Functions | Protected Attributes
Buzzer Class Reference

C++ API for Buzzer component. More...

Detailed Description

This file defines the Buzzer C++ interface for libbuzzer

// create Buzzer instance
upm::Buzzer* sound = new upm::Buzzer(5);
// print sensor name
std::cout << sound->name() << std::endl;
// play sound (DO, RE, ME, etc...)
for (int chord_ind = 0; chord_ind < 7; chord_ind++) {
// play one second for each chord
std::cout << sound->playSound(chord[chord_ind], 1000000) << std::endl;
usleep(100000);
}

Public Member Functions

 Buzzer (int pinNumber)
 
 ~Buzzer ()
 
int playSound (int note, int delay)
 
std::string name ()
 

Protected Attributes

std::string m_name
 

Constructor & Destructor Documentation

Buzzer ( int  pinNumber)

Instanciates a Buzzer object

Parameters
pinNumberBuzzer pin number
~Buzzer ( )

Buzzer object destructor.

Member Function Documentation

int playSound ( int  note,
int  delay 
)

Play chords.

Parameters
notechords (DO, RE, ME, etc...)
delaytime in microsec for playing the sound
std::string name ( )
inline

Return name of the component


The documentation for this class was generated from the following files: