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.
Diff: main.cpp
- Revision:
- 0:07997c7eb70b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Feb 18 17:37:33 2021 +0000 @@ -0,0 +1,62 @@ +#include "mbed.h" +#include "sirena.h" +DigitalOut led_alarm(LED2); //zelena integrirana ledica na nucleo sučelju +DigitalOut dovod_plin(D2); // zuta ledica +DigitalOut prskalice_vode(D3); //zelena ledica +DigitalOut ventilacija(D4); //crvena ledica +DigitalIn dim_senzor(D5); +sirena buzzer(D9); +InterruptIn button(USER_BUTTON); + +Ticker flipper; +Timer vrijeme; +Timer debounce; + +void flip(void); +void sirena_alarm(void); +void interrupt (void); + +Timer timer1; + +int main() +{ + debounce.start(); + dim_senzor.mode(PullDown); + button.rise(&interrupt); + flipper.attach(&flip,0.3); + timer1.start(); + +while (1) +{ + if (dim_senzor==1) + { + dovod_plin = 0; + prskalice_vode = 1; + ventilacija = 0; + } + else if (dim_senzor==0) + { + dovod_plin = 1; + prskalice_vode = 0; + ventilacija = 1; + } + } + + } + void flip() +{ + if (dim_senzor==1) + led_alarm=!led_alarm; +} +void interrupt() +{ + if (debounce.read_ms()>200){ + void sirena_alarm(); + { + buzzer.beep(500,10); //buzzer radi frekvencijom 500 Hz, 10 s + vrijeme.start(); + } + timer1.reset(); +} + debounce.reset(); +}