tes ir atas semua

Dependencies:   mbed ADS1115 StepperMotor SRF05 TPA81new

Committer:
hisyamfs
Date:
Sun Dec 16 01:53:07 2018 +0000
Revision:
12:1e3227a6fcd7
Parent:
10:8722053fb75c
Child:
13:0c5942931cad
test board v1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hisyamfs 12:1e3227a6fcd7 1 #include "mbed.h"
hisyamfs 12:1e3227a6fcd7 2 #include "Stepper.h"
hisyamfs 12:1e3227a6fcd7 3 #include "AX12.h"
hisyamfs 12:1e3227a6fcd7 4 #include "Uvtron.h"
hisyamfs 12:1e3227a6fcd7 5 #include "TPA81new.h"
Ezeuz 4:9932af380e56 6
hisyamfs 12:1e3227a6fcd7 7 #define WAIT_TIME 0.02
Ezeuz 6:69c59bcab6ea 8
hisyamfs 12:1e3227a6fcd7 9 Serial pc(USBTX, USBRX);
hisyamfs 12:1e3227a6fcd7 10 // stepper(PinName _en, PinName ms1, PinName ms2, PinName ms3, PinName _stepPin, PinName dir);
hisyamfs 12:1e3227a6fcd7 11 stepper s(PC_6, PC_8, PA_12, PC_7, PA_11, PB_12);
hisyamfs 12:1e3227a6fcd7 12 Uvtron uv(PC_12);
Ezeuz 4:9932af380e56 13
hisyamfs 12:1e3227a6fcd7 14 AX12 servo1(PC_10, PC_11, PA_13, 6, 1000000); // tx, rx, tx_enable, servo ID, baud rate
hisyamfs 12:1e3227a6fcd7 15 AX12 servo2(PC_10, PC_11, PA_13, 22, 1000000);
hisyamfs 12:1e3227a6fcd7 16 AX12 servo3(PC_10, PC_11, PA_13, 19, 1000000);
Ezeuz 4:9932af380e56 17
hisyamfs 12:1e3227a6fcd7 18 TPA81 tpay(PB_9, PB_8, 0xDE);
hisyamfs 12:1e3227a6fcd7 19 DigitalOut led(LED1);
dmgongora 0:79e2a8171b16 20
dmgongora 0:79e2a8171b16 21 int main()
hisyamfs 12:1e3227a6fcd7 22 {
hisyamfs 12:1e3227a6fcd7 23 s.enable();
hisyamfs 12:1e3227a6fcd7 24 while (1)
hisyamfs 12:1e3227a6fcd7 25 {
Ezeuz 6:69c59bcab6ea 26
hisyamfs 12:1e3227a6fcd7 27 // TPA
hisyamfs 12:1e3227a6fcd7 28 pc.printf("%d", tpay.getTemp(0));
hisyamfs 12:1e3227a6fcd7 29 int i;
hisyamfs 12:1e3227a6fcd7 30 pc.printf("\nTPA Y \n");
hisyamfs 12:1e3227a6fcd7 31 tpay.Read();
hisyamfs 12:1e3227a6fcd7 32 for (i=2; i<=9; i++) {
hisyamfs 12:1e3227a6fcd7 33 pc.printf("%d ",tpay.getTemp(i));
Ezeuz 8:5e1854c119ba 34 }
Ezeuz 6:69c59bcab6ea 35
hisyamfs 12:1e3227a6fcd7 36 // Stepper
hisyamfs 12:1e3227a6fcd7 37 pc.printf("Stepper\n");
hisyamfs 12:1e3227a6fcd7 38 s.step(1, 1, 1/WAIT_TIME);
Ezeuz 8:5e1854c119ba 39
hisyamfs 12:1e3227a6fcd7 40 // Servo
hisyamfs 12:1e3227a6fcd7 41 servo1.SetGoal(240);
hisyamfs 12:1e3227a6fcd7 42 servo2.SetGoal(240);
hisyamfs 12:1e3227a6fcd7 43 servo3.SetGoal(240);
hisyamfs 12:1e3227a6fcd7 44 pc.printf("Servo : 240\n");
hisyamfs 12:1e3227a6fcd7 45 led = 1;
hisyamfs 12:1e3227a6fcd7 46 wait(1);
hisyamfs 12:1e3227a6fcd7 47 servo1.SetGoal(150);
hisyamfs 12:1e3227a6fcd7 48 servo2.SetGoal(150);
hisyamfs 12:1e3227a6fcd7 49 servo3.SetGoal(150);
hisyamfs 12:1e3227a6fcd7 50 pc.printf("Servo : 150\n");
hisyamfs 12:1e3227a6fcd7 51 led = 0;
hisyamfs 12:1e3227a6fcd7 52 wait(1);
Ezeuz 8:5e1854c119ba 53
hisyamfs 12:1e3227a6fcd7 54 // Uvtron
hisyamfs 12:1e3227a6fcd7 55 uv.Read();
hisyamfs 12:1e3227a6fcd7 56 int read = uv.Flag;
hisyamfs 12:1e3227a6fcd7 57 if (read) pc.printf("FIRE DETECTED\n");
hisyamfs 12:1e3227a6fcd7 58 else pc.printf("NOT DETECTED\n");
hisyamfs 12:1e3227a6fcd7 59 }
hisyamfs 12:1e3227a6fcd7 60 }