Utilities classes for the Zumo Robot
Dependents: ZumoRobotBluetoothControlled Fsl_Zumo
This library represents some useful code for controlling your Zumo Robot.
Diff: Buzzer.cpp
- Revision:
- 4:dcd52a961392
- Child:
- 5:5e12111ef01f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Buzzer.cpp Thu Nov 27 16:08:05 2014 +0000 @@ -0,0 +1,33 @@ +// 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 \ No newline at end of file