Franjo Tudek
Dependencies: mbed SeeedShieldBot BluetoothSerial
Revision 0:90b835ec611a, committed 2021-05-07
- Comitter:
- franjo1
- Date:
- Fri May 07 15:22:28 2021 +0000
- Commit message:
- Franjo Tudek
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BluetoothSerial.lib Fri May 07 15:22:28 2021 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/yihui/code/BluetoothSerial/#f56002898ee8
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Doorbell.cpp Fri May 07 15:22:28 2021 +0000 @@ -0,0 +1,12 @@ +#include "Doorbell.h" +#include "mbed.h" +Bell::Bell(PinName Piezzo) : Buzzer(Piezzo) { + +} + +void Bell::Buzz(int f, int b) { + + Buzzer.period(1/(f)); // set PWM period + Buzzer=0.5; // set duty cycle + wait(0.5*b); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Doorbell.h Fri May 07 15:22:28 2021 +0000 @@ -0,0 +1,12 @@ +#ifndef DoorBell_h +#define DoorBell_h +#include "mbed.h" +class Bell{ +public: + Bell(PinName Buzzer); + void Buzz(int f, int b); + +private: + PwmOut Buzzer; +}; +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SeeedShieldBot.lib Fri May 07 15:22:28 2021 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/teams/components/code/SeeedShieldBot/#9fd1722259a1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri May 07 15:22:28 2021 +0000 @@ -0,0 +1,33 @@ +#include "mbed.h" +#include "Doorbell.h" + +Bell zujalica (D5); +DigitalOut ledica(D6); +InterruptIn tipkalo(D4); +int frequency[] = {261,207,196,220,196,1,246,261}; +int beat[] = {4,8,8,4,4,4,4,4 }; +int t=0, i=0; +Ticker tik1; +void tiker1() +{ + t=t+1; +} +void zvono() +{ + ledica=1; + for(i=0;i<8;i++){ + zujalica.Buzz(frequency[i], beat[i]); + } + ledica=0; +} +int main() { + tik1.attach(&tiker1, 0.01); + while(1) { + tipkalo.fall(&zvono); + if(t>=0 && t<50) + ledica=1; + if(t>=100) + t=0; + } +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri May 07 15:22:28 2021 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file