tes ir atas semua

Dependencies:   mbed ADS1115 StepperMotor SRF05 TPA81new

Committer:
hisyamfs
Date:
Mon Jan 21 12:37:28 2019 +0000
Revision:
20:1b0a265598c0
Parent:
19:9a7b34bedc6c
Child:
21:bfb064f77f88
sound

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hisyamfs 12:1e3227a6fcd7 1 #include "mbed.h"
hisyamfs 12:1e3227a6fcd7 2 #include "TPA81new.h"
hisyamfs 16:771d84a80e3d 3 #include "SRF05.h"
hisyamfs 19:9a7b34bedc6c 4 #include "Uvtron.h"
hisyamfs 16:771d84a80e3d 5
hisyamfs 16:771d84a80e3d 6 #define LCD_D4_DIG PA_15
hisyamfs 16:771d84a80e3d 7 #define LCD_D5_DIG PA_14
hisyamfs 16:771d84a80e3d 8 #define LCD_E_DIG PC_15
hisyamfs 16:771d84a80e3d 9 #define LCD_RS_DIG PB_7
hisyamfs 14:207770fefedf 10
hisyamfs 15:da7a15289893 11 Serial pc(USBTX,USBRX);
hisyamfs 17:fd06e8104835 12
hisyamfs 17:fd06e8104835 13 // TPA
hisyamfs 15:da7a15289893 14 TPA81 tpax(PB_9, PB_8, 0xDC);
hisyamfs 15:da7a15289893 15 TPA81 tpay(PB_3, PB_10, 0xDE);
dmgongora 0:79e2a8171b16 16
hisyamfs 17:fd06e8104835 17 // Ultrasonik
hisyamfs 16:771d84a80e3d 18 SRF05 srf1(PC_13, PA_14); // trigger, echo
hisyamfs 16:771d84a80e3d 19 SRF05 srf2(PA_15, PB_7); // trigger, echo
hisyamfs 16:771d84a80e3d 20
hisyamfs 18:f3b23331090f 21 DigitalOut relay(PB_2);
hisyamfs 18:f3b23331090f 22
hisyamfs 17:fd06e8104835 23 // UVTron
hisyamfs 17:fd06e8104835 24 Uvtron uv(PC_12);
hisyamfs 17:fd06e8104835 25
hisyamfs 19:9a7b34bedc6c 26 // Sound
hisyamfs 20:1b0a265598c0 27 DigitalIn sound(PA_3);
hisyamfs 19:9a7b34bedc6c 28
dmgongora 0:79e2a8171b16 29 int main()
hisyamfs 12:1e3227a6fcd7 30 {
hisyamfs 15:da7a15289893 31 //tpax.changeaddress(0xDC,0xDE);
hisyamfs 20:1b0a265598c0 32 while(sound.read()){}
hisyamfs 20:1b0a265598c0 33 pc.printf("Sound Detected\n");
hisyamfs 15:da7a15289893 34 while(1) {
hisyamfs 15:da7a15289893 35 pc.printf("%d", tpay.getTemp(0));
hisyamfs 15:da7a15289893 36 int i;
hisyamfs 15:da7a15289893 37 pc.printf("\nTPA Y \n");
hisyamfs 15:da7a15289893 38 tpay.Read();
hisyamfs 15:da7a15289893 39 for (i=2; i<=9; i++) {
hisyamfs 15:da7a15289893 40 pc.printf("%d ",tpay.getTemp(i));
Ezeuz 8:5e1854c119ba 41 }
hisyamfs 15:da7a15289893 42
hisyamfs 15:da7a15289893 43 pc.printf("\nTPA X \n");
hisyamfs 15:da7a15289893 44 tpax.Read();
hisyamfs 15:da7a15289893 45 for (i=2; i<=9; i++) {
hisyamfs 15:da7a15289893 46 pc.printf("%d ",tpax.getTemp(i));
hisyamfs 15:da7a15289893 47 }
hisyamfs 15:da7a15289893 48 pc.printf("\n");
hisyamfs 15:da7a15289893 49
hisyamfs 16:771d84a80e3d 50 pc.printf("us 1: %.2f\tus 2:%.2f\n", srf1.read(), srf2.read());
hisyamfs 17:fd06e8104835 51
hisyamfs 17:fd06e8104835 52 uv.Read();
hisyamfs 17:fd06e8104835 53 int read = uv.Flag;
hisyamfs 17:fd06e8104835 54 if (read) pc.printf("FIRE DETECTED\n");
hisyamfs 17:fd06e8104835 55 else pc.printf("NOT DETECTED\n");
hisyamfs 15:da7a15289893 56 wait(0.5); // 200 ms
hisyamfs 15:da7a15289893 57
hisyamfs 18:f3b23331090f 58 relay = 1;
hisyamfs 18:f3b23331090f 59 pc.printf("RELAY ON");
hisyamfs 18:f3b23331090f 60 wait(0.5);
hisyamfs 18:f3b23331090f 61 relay = 0;
hisyamfs 18:f3b23331090f 62 pc.printf("RELAY OFF");
hisyamfs 14:207770fefedf 63 }
hisyamfs 15:da7a15289893 64 }