Utilities classes for the Zumo Robot

Dependents:   ZumoRobotBluetoothControlled Fsl_Zumo

This library represents some useful code for controlling your Zumo Robot.

Buzzer.cpp

Committer:
catalincraciun7
Date:
2014-11-27
Revision:
4:dcd52a961392
Child:
5:5e12111ef01f

File content as of revision 4:dcd52a961392:

// Craciun Catalin
//  Buzzer.cpp
//   © 2014 Catalin Craciun

#ifndef BuzzerCpp
#define BuzzerCpp

#include "Buzzer.h"

Buzzer::Buzzer(PinName buzzerPinName):buzzerPin(buzzerPinName) {
 
    // Initialising
    buzzerPin.write(0.0f);
}

Buzzer::~Buzzer() {
    
    // Deinitialising
}

void Buzzer::stopBeep() {
    
    buzzerPin.write(0.0f);
}

void Buzzer::startBeep(float frequency, float duration) {
    
    buzzerPin.period(1/frequency);   
    buzzerPin.write(0.75f);
    timeout.attach(this, &Buzzer::stopBeep, duration);
}

#endif // BuzzerCpp