Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed Servo ros_lib_kinetic
Buzzer/Buzzer.cpp@6:2cc2aac35868, 2019-11-12 (annotated)
- Committer:
- Stumi
- Date:
- Tue Nov 12 12:56:02 2019 +0000
- Revision:
- 6:2cc2aac35868
Added buzzer functionality; Added buzzer and LED into obstacle avoidance routine; Made class declaration for led and buzzer in motor.cpp NOT MAIN
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Stumi | 6:2cc2aac35868 | 1 | #include "Buzzer.h" |
| Stumi | 6:2cc2aac35868 | 2 | |
| Stumi | 6:2cc2aac35868 | 3 | cBuzzer::cBuzzer(DigitalOut Buzz): _Buzz(Buzz) |
| Stumi | 6:2cc2aac35868 | 4 | { |
| Stumi | 6:2cc2aac35868 | 5 | _Buzz = 0; |
| Stumi | 6:2cc2aac35868 | 6 | |
| Stumi | 6:2cc2aac35868 | 7 | } |
| Stumi | 6:2cc2aac35868 | 8 | |
| Stumi | 6:2cc2aac35868 | 9 | /*-------------------------------------------------------------------------------- |
| Stumi | 6:2cc2aac35868 | 10 | Function name: short_buzz() |
| Stumi | 6:2cc2aac35868 | 11 | Input Parameters: N/A |
| Stumi | 6:2cc2aac35868 | 12 | Output Parameters: N/A |
| Stumi | 6:2cc2aac35868 | 13 | Description: Turns the buzzer on for a short period of time |
| Stumi | 6:2cc2aac35868 | 14 | ----------------------------------------------------------------------------------*/ |
| Stumi | 6:2cc2aac35868 | 15 | void cBuzzer::Beep() |
| Stumi | 6:2cc2aac35868 | 16 | { |
| Stumi | 6:2cc2aac35868 | 17 | _Buzz =1; |
| Stumi | 6:2cc2aac35868 | 18 | wait (0.5); |
| Stumi | 6:2cc2aac35868 | 19 | _Buzz =0; |
| Stumi | 6:2cc2aac35868 | 20 | |
| Stumi | 6:2cc2aac35868 | 21 | } |
| Stumi | 6:2cc2aac35868 | 22 | /*-------------------------------------------------------------------------------- |
| Stumi | 6:2cc2aac35868 | 23 | Function name: buzzer_on() |
| Stumi | 6:2cc2aac35868 | 24 | Input Parameters: N/A |
| Stumi | 6:2cc2aac35868 | 25 | Output Parameters: N/A |
| Stumi | 6:2cc2aac35868 | 26 | Description: Turns the buzzer on indefinitely |
| Stumi | 6:2cc2aac35868 | 27 | ----------------------------------------------------------------------------------*/ |
| Stumi | 6:2cc2aac35868 | 28 | void cBuzzer::buzzer_on() |
| Stumi | 6:2cc2aac35868 | 29 | { |
| Stumi | 6:2cc2aac35868 | 30 | _Buzz = 1; //Enable Buzzer |
| Stumi | 6:2cc2aac35868 | 31 | } |
| Stumi | 6:2cc2aac35868 | 32 | |
| Stumi | 6:2cc2aac35868 | 33 | /*-------------------------------------------------------------------------------- |
| Stumi | 6:2cc2aac35868 | 34 | Function name: buzz_off() |
| Stumi | 6:2cc2aac35868 | 35 | Input Parameters: N/A |
| Stumi | 6:2cc2aac35868 | 36 | Output Parameters: N/A |
| Stumi | 6:2cc2aac35868 | 37 | Description: Turns buzzer off indefinitely |
| Stumi | 6:2cc2aac35868 | 38 | ----------------------------------------------------------------------------------*/ |
| Stumi | 6:2cc2aac35868 | 39 | void cBuzzer::buzz_off() |
| Stumi | 6:2cc2aac35868 | 40 | { |
| Stumi | 6:2cc2aac35868 | 41 | _Buzz = 0; //Disable Buzzer |
| Stumi | 6:2cc2aac35868 | 42 | } |