tes ir atas semua

Dependencies:   mbed ADS1115 StepperMotor SRF05 TPA81new

main.cpp

Committer:
hisyamfs
Date:
2018-12-16
Revision:
12:1e3227a6fcd7
Parent:
10:8722053fb75c
Child:
13:0c5942931cad

File content as of revision 12:1e3227a6fcd7:

#include "mbed.h"
#include "Stepper.h"
#include "AX12.h"
#include "Uvtron.h"
#include "TPA81new.h"

#define WAIT_TIME 0.02

Serial pc(USBTX, USBRX);
// stepper(PinName _en, PinName ms1, PinName ms2, PinName ms3, PinName _stepPin, PinName dir);
stepper s(PC_6, PC_8, PA_12, PC_7, PA_11, PB_12);
Uvtron uv(PC_12);

AX12 servo1(PC_10, PC_11, PA_13, 6,  1000000); // tx, rx, tx_enable, servo ID, baud rate  
AX12 servo2(PC_10, PC_11, PA_13, 22, 1000000);
AX12 servo3(PC_10, PC_11, PA_13, 19, 1000000);

TPA81 tpay(PB_9, PB_8, 0xDE);
DigitalOut led(LED1);

int main()
{
    s.enable();
    while (1)
    {
        
        // TPA
        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));
        }
        
        // Stepper
        pc.printf("Stepper\n");
        s.step(1, 1, 1/WAIT_TIME);
        
        // Servo
        servo1.SetGoal(240);
        servo2.SetGoal(240);
        servo3.SetGoal(240);
        pc.printf("Servo : 240\n");
        led = 1;
        wait(1);
        servo1.SetGoal(150);
        servo2.SetGoal(150);
        servo3.SetGoal(150);
        pc.printf("Servo : 150\n");
        led = 0;
        wait(1);
        
        // Uvtron
        uv.Read();
        int read = uv.Flag;
        if (read) pc.printf("FIRE DETECTED\n");
        else pc.printf("NOT DETECTED\n");
    }    
}