Program opisuje signalizaciju otvaranja garaznih vrata. Kada su vrata zatvorena svjetli crvena ledica, na pritisak tipkala pokreće se otvaranje vrata. signalizacija otvaranja vrata je titrajuća zuta ledica i zvuk iz buzzera. Kada su vrata otvorena svjetli zelena ledica.
Dependencies: Piezo_zvucnik
buzzer.cpp@0:054375111414, 2021-12-09 (annotated)
- Committer:
- dgerin
- Date:
- Thu Dec 09 07:52:53 2021 +0000
- Revision:
- 0:054375111414
Konstrukcijski zadatak
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dgerin | 0:054375111414 | 1 | #include "buzzer.h" |
dgerin | 0:054375111414 | 2 | #include "mbed.h" |
dgerin | 0:054375111414 | 3 | |
dgerin | 0:054375111414 | 4 | using namespace mbed; |
dgerin | 0:054375111414 | 5 | |
dgerin | 0:054375111414 | 6 | Beep::Beep(PinName pin) : _pwm(pin) |
dgerin | 0:054375111414 | 7 | { |
dgerin | 0:054375111414 | 8 | _pwm.write(0.0); |
dgerin | 0:054375111414 | 9 | } |
dgerin | 0:054375111414 | 10 | |
dgerin | 0:054375111414 | 11 | void Beep::nobeep() |
dgerin | 0:054375111414 | 12 | { |
dgerin | 0:054375111414 | 13 | _pwm.write(0.0); |
dgerin | 0:054375111414 | 14 | } |
dgerin | 0:054375111414 | 15 | |
dgerin | 0:054375111414 | 16 | |
dgerin | 0:054375111414 | 17 | void Beep::beep(float freq, float time) |
dgerin | 0:054375111414 | 18 | { |
dgerin | 0:054375111414 | 19 | |
dgerin | 0:054375111414 | 20 | _pwm.period(1.0/freq); |
dgerin | 0:054375111414 | 21 | _pwm.write(0.5); |
dgerin | 0:054375111414 | 22 | toff.attach(this,&Beep::nobeep, time); |
dgerin | 0:054375111414 | 23 | } |