Franjo Tudek

Dependencies:   mbed SeeedShieldBot BluetoothSerial

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "Doorbell.h"
00003 
00004 Bell zujalica (D5);
00005 DigitalOut ledica(D6);
00006 InterruptIn tipkalo(D4);
00007 int frequency[] = {261,207,196,220,196,1,246,261};
00008 int beat[] = {4,8,8,4,4,4,4,4 };
00009 int t=0, i=0;
00010 Ticker tik1;
00011 void tiker1()
00012 {
00013     t=t+1;
00014 }
00015 void zvono()
00016 {
00017    ledica=1;
00018    for(i=0;i<8;i++){
00019         zujalica.Buzz(frequency[i], beat[i]);
00020         }
00021         ledica=0;
00022 }
00023 int main() {
00024      tik1.attach(&tiker1, 0.01);
00025     while(1) {
00026         tipkalo.fall(&zvono);
00027       if(t>=0 && t<50)
00028       ledica=1;
00029       if(t>=100)
00030       t=0;
00031     }
00032 }
00033