Utilities classes for the Zumo Robot

Dependents:   ZumoRobotBluetoothControlled Fsl_Zumo

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

Committer:
catalincraciun7
Date:
Thu Dec 11 20:52:06 2014 +0000
Revision:
5:5e12111ef01f
Parent:
4:dcd52a961392
Child:
6:7740c9d8d834
Motors done!

Who changed what in which revision?

UserRevisionLine numberNew contents of line
catalincraciun7 4:dcd52a961392 1 // Craciun Catalin
catalincraciun7 4:dcd52a961392 2 // Buzzer.cpp
catalincraciun7 4:dcd52a961392 3 // © 2014 Catalin Craciun
catalincraciun7 4:dcd52a961392 4
catalincraciun7 4:dcd52a961392 5 #ifndef BuzzerCpp
catalincraciun7 4:dcd52a961392 6 #define BuzzerCpp
catalincraciun7 4:dcd52a961392 7
catalincraciun7 4:dcd52a961392 8 #include "Buzzer.h"
catalincraciun7 4:dcd52a961392 9
catalincraciun7 4:dcd52a961392 10 Buzzer::Buzzer(PinName buzzerPinName):buzzerPin(buzzerPinName) {
catalincraciun7 4:dcd52a961392 11
catalincraciun7 4:dcd52a961392 12 // Initialising
catalincraciun7 5:5e12111ef01f 13 buzzerPin.period_us(0);
catalincraciun7 5:5e12111ef01f 14 buzzerPin.pulsewidth_us(0);
catalincraciun7 4:dcd52a961392 15 }
catalincraciun7 4:dcd52a961392 16
catalincraciun7 4:dcd52a961392 17 Buzzer::~Buzzer() {
catalincraciun7 4:dcd52a961392 18
catalincraciun7 4:dcd52a961392 19 // Deinitialising
catalincraciun7 4:dcd52a961392 20 }
catalincraciun7 4:dcd52a961392 21
catalincraciun7 4:dcd52a961392 22 void Buzzer::stopBeep() {
catalincraciun7 4:dcd52a961392 23
catalincraciun7 5:5e12111ef01f 24 buzzerPin.period_us(0);
catalincraciun7 5:5e12111ef01f 25 buzzerPin.pulsewidth_us(0);
catalincraciun7 4:dcd52a961392 26 }
catalincraciun7 4:dcd52a961392 27
catalincraciun7 4:dcd52a961392 28 void Buzzer::startBeep(float frequency, float duration) {
catalincraciun7 4:dcd52a961392 29
catalincraciun7 4:dcd52a961392 30 buzzerPin.period(1/frequency);
catalincraciun7 5:5e12111ef01f 31 buzzerPin.pulsewidth_us(100);
catalincraciun7 4:dcd52a961392 32 timeout.attach(this, &Buzzer::stopBeep, duration);
catalincraciun7 4:dcd52a961392 33 }
catalincraciun7 4:dcd52a961392 34
catalincraciun7 4:dcd52a961392 35 #endif // BuzzerCpp