tes ir atas semua

Dependencies:   mbed ADS1115 StepperMotor SRF05 TPA81new

main.cpp

Committer:
hisyamfs
Date:
2019-01-21
Revision:
19:9a7b34bedc6c
Parent:
18:f3b23331090f
Child:
20:1b0a265598c0

File content as of revision 19:9a7b34bedc6c:

#include "mbed.h"
#include "TPA81new.h"
#include "SRF05.h"
#include "Uvtron.h"

#define LCD_D4_DIG PA_15
#define LCD_D5_DIG PA_14
#define LCD_E_DIG PC_15
#define LCD_RS_DIG PB_7

Serial pc(USBTX,USBRX);

// TPA
TPA81 tpax(PB_9, PB_8, 0xDC);
TPA81 tpay(PB_3, PB_10, 0xDE);

// Ultrasonik
SRF05 srf1(PC_13, PA_14); // trigger, echo
SRF05 srf2(PA_15, PB_7); // trigger, echo

DigitalOut relay(PB_2);

// UVTron
Uvtron uv(PC_12); 

// Sound
//DigitalIn(PA_3);

int main()
{
    //tpax.changeaddress(0xDC,0xDE);
    while(1) {
        pc.printf("%d", tpay.getTemp(0));
        int i;
        pc.printf("\nTPA Y \n");
        tpay.Read();
        for (i=2; i<=9; i++) {
            pc.printf("%d ",tpay.getTemp(i));
        }

        pc.printf("\nTPA X \n");
        tpax.Read();
        for (i=2; i<=9; i++) {
            pc.printf("%d ",tpax.getTemp(i));
        }
        pc.printf("\n");

        pc.printf("us 1: %.2f\tus 2:%.2f\n", srf1.read(), srf2.read());
        
        uv.Read();
        int read = uv.Flag;
        if (read) pc.printf("FIRE DETECTED\n");
        else pc.printf("NOT DETECTED\n");
        wait(0.5); // 200 ms

        relay = 1;
        pc.printf("RELAY ON");
        wait(0.5);
        relay = 0;
        pc.printf("RELAY OFF");        
    }
}