tes ir atas semua

Dependencies:   mbed ADS1115 StepperMotor SRF05 TPA81new

Committer:
hisyamfs
Date:
Mon Jan 21 12:41:08 2019 +0000
Revision:
21:bfb064f77f88
Parent:
20:1b0a265598c0
Child:
25:a75d6875cb55
line

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
hisyamfs 21:bfb064f77f88 29 // Line
hisyamfs 21:bfb064f77f88 30 AnalogIn line(PC_1);
hisyamfs 21:bfb064f77f88 31
dmgongora 0:79e2a8171b16 32 int main()
hisyamfs 12:1e3227a6fcd7 33 {
hisyamfs 15:da7a15289893 34 //tpax.changeaddress(0xDC,0xDE);
hisyamfs 20:1b0a265598c0 35 while(sound.read()){}
hisyamfs 20:1b0a265598c0 36 pc.printf("Sound Detected\n");
hisyamfs 15:da7a15289893 37 while(1) {
hisyamfs 15:da7a15289893 38 pc.printf("%d", tpay.getTemp(0));
hisyamfs 15:da7a15289893 39 int i;
hisyamfs 15:da7a15289893 40 pc.printf("\nTPA Y \n");
hisyamfs 15:da7a15289893 41 tpay.Read();
hisyamfs 15:da7a15289893 42 for (i=2; i<=9; i++) {
hisyamfs 15:da7a15289893 43 pc.printf("%d ",tpay.getTemp(i));
Ezeuz 8:5e1854c119ba 44 }
hisyamfs 15:da7a15289893 45
hisyamfs 15:da7a15289893 46 pc.printf("\nTPA X \n");
hisyamfs 15:da7a15289893 47 tpax.Read();
hisyamfs 15:da7a15289893 48 for (i=2; i<=9; i++) {
hisyamfs 15:da7a15289893 49 pc.printf("%d ",tpax.getTemp(i));
hisyamfs 15:da7a15289893 50 }
hisyamfs 15:da7a15289893 51 pc.printf("\n");
hisyamfs 15:da7a15289893 52
hisyamfs 16:771d84a80e3d 53 pc.printf("us 1: %.2f\tus 2:%.2f\n", srf1.read(), srf2.read());
hisyamfs 17:fd06e8104835 54
hisyamfs 17:fd06e8104835 55 uv.Read();
hisyamfs 17:fd06e8104835 56 int read = uv.Flag;
hisyamfs 17:fd06e8104835 57 if (read) pc.printf("FIRE DETECTED\n");
hisyamfs 17:fd06e8104835 58 else pc.printf("NOT DETECTED\n");
hisyamfs 15:da7a15289893 59 wait(0.5); // 200 ms
hisyamfs 15:da7a15289893 60
hisyamfs 18:f3b23331090f 61 relay = 1;
hisyamfs 21:bfb064f77f88 62 pc.printf("RELAY ON\n");
hisyamfs 18:f3b23331090f 63 wait(0.5);
hisyamfs 18:f3b23331090f 64 relay = 0;
hisyamfs 21:bfb064f77f88 65 pc.printf("RELAY OFF\n");
hisyamfs 21:bfb064f77f88 66
hisyamfs 21:bfb064f77f88 67 pc.printf("Line = %.2f\n", 3300*line.read());
hisyamfs 14:207770fefedf 68 }
hisyamfs 15:da7a15289893 69 }