tes ir atas semua

Dependencies:   mbed ADS1115 StepperMotor SRF05 TPA81new

Revision:
15:da7a15289893
Parent:
14:207770fefedf
Child:
16:771d84a80e3d
--- a/main.cpp	Thu Jan 17 13:23:10 2019 +0000
+++ b/main.cpp	Thu Jan 17 13:24:13 2019 +0000
@@ -1,164 +1,32 @@
 #include "mbed.h"
-#include "Stepper.h"
-#include "AX12.h"
-#include "Uvtron.h"
 #include "TPA81new.h"
-#include "SRF05.h"
-#include "SharpIR.h"
-
-#define WAIT_TIME 0.02
-
-Serial pc(USBTX, USBRX);
-
-// Kaki
-AX12 servo1(PC_10, PC_11, PA_13, 1, 1000000); // tx, rx, tx_enable, servo ID, baud rate  
 
-// Kepala
-// Infrared
-SharpIR irb1(PA_0);
-SharpIR irb2(PA_1);
-SharpIR irb3(PA_4);
-SharpIR irb4(PB_0);
-SharpIR ira1(PC_5);
-SharpIR ira2(PA_5);
-SharpIR ira3(PC_2);
-SharpIR ira4(PC_3);
-SharpIR ira5(PB_1);
-SharpIR ira6(PC_4);
-SharpIR ira7(PA_6);
-SharpIR ira8(PA_7);
-// Kompas
-// MPU9255 mpu(PB_4, PA_8)
-// Line
-AnalogIn line(PC_1);
-// Sound activation
-DigitalIn sound(PA_3);
-
-// Topi
-// TPA
-TPA81 tpa1(PB_9, PB_8, 0xDC); // sda, scl, id
-TPA81 tpa2(PB_3, PB_10, 0xDE);
-// Ultrasonik
-SRF05 us1(PB_7, PB_15); // trigger, echo
-SRF05 us2(PC_15, PC_14); // trigger echo
-// Uvtron
-Uvtron uv(PC_12);
-DigitalOut led(LED1);
-// stepper
-stepper s(PC_6, PC_8, PA_12, PC_7, PA_11, PB_12); // _en, ms1, ms2, ms3, _step, dir
-// relay
-DigitalOut relay(PB_2);
+Serial pc(USBTX,USBRX);
+TPA81 tpax(PB_9, PB_8, 0xDC);
+TPA81 tpay(PB_3, PB_10, 0xDE);
 
 int main()
 {
-    pc.printf("Memulai test\n");
-    pc.printf("3\n");
-    wait(1);
-    pc.printf("2\n");
-    wait(1);
-    pc.printf("1\n");
-    wait(1);
-    while (1)
-    {
-       // Servo
-//       pc.printf("Test Servo : 240\n");
-//       int degrees1 = 240;
-//       float speed1 = 1.0f;
-//       servo1.MultSetGoal(degrees1, speed1, 
-//                        degrees1, speed1, 
-//                        degrees1, speed1, 
-//                        degrees1, speed1, 
-//                        degrees1, speed1, 
-//                        degrees1, speed1, 
-//                        degrees1, speed1, 
-//                        degrees1, speed1, 
-//                        degrees1, speed1, 
-//                        degrees1, speed1, 
-//                        degrees1, speed1, 
-//                        degrees1, speed1, 
-//                        degrees1, speed1, 
-//                        degrees1, speed1, 
-//                        degrees1, speed1, 
-//                        degrees1, speed1, 
-//                        degrees1, speed1, 
-//                        degrees1, speed1);
-//        degrees1 = 150;
-//        pc.printf("150/n");
-//        servo1.MultSetGoal(degrees1, speed1, 
-//                        degrees1, speed1, 
-//                        degrees1, speed1, 
-//                        degrees1, speed1, 
-//                        degrees1, speed1, 
-//                        degrees1, speed1, 
-//                        degrees1, speed1, 
-//                        degrees1, speed1, 
-//                        degrees1, speed1, 
-//                        degrees1, speed1, 
-//                        degrees1, speed1, 
-//                        degrees1, speed1, 
-//                        degrees1, speed1, 
-//                        degrees1, speed1, 
-//                        degrees1, speed1, 
-//                        degrees1, speed1, 
-//                        degrees1, speed1, 
-//                        degrees1, speed1);
-                        
-       // Infrared Bawah
-       //float b1 = irb1.read();
-//       float b2 = irb2.read();
-//       float b3 = irb3.read();
-//       float b4 = irb4.read();
-//       pc.printf("IR bawah\n");
-//       pc.printf("    %.f    \n", b1);
-//       pc.printf("%.f     %.f\n", b2, b4);
-//       pc.printf("    %.f    \n", b3);
-       
-       // Line
-       pc.printf("Line : %.f\n", line.read());
-       
-       // Infrared Atas
-       //float a1 = ira1.read();
-//       float a2 = ira2.read();
-//       float a3 = ira3.read();
-//       float a4 = ira4.read();
-//       float a5 = ira5.read();
-//       float a6 = ira6.read();
-//       float a7 = ira7.read();
-//       float a8 = ira8.read();
-//       pc.printf("IR atas\n");
-//       pc.printf("   %.f  %.f\n", a2, a1);
-//       pc.printf("%.f         %.f\n", a3, a8);
-//       pc.printf("%.f         %.f\n", a4, a7);
-//       pc.printf("   %.f  %.f\n", a5, a6);
-//       
-       // Sound activation
-       
-        // Stepper
-        //pc.printf("Stepper 1 putaran\n");
-//        for(int i=0; i<200; i++)
-//        {
-//            s.step(1, 1, 50);     
-//        } 
-           
-       // TPA
-       tpa1.Read();
-       tpa2.Read();
-       pc.printf("TPA 1\tTPA 2\n");
-        for (int i = 0; i < 8; i++)
-        {
-            pc.printf("%d\t%d\n", tpa1.Data[i], tpa2.Data[i]);  
+    //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));
         }
-        
-       // Uvtron
-       uv.Read();
-       int read = uv.Flag;
-       pc.printf("UVTron = %d\n", read);
-       // Ultrasonik
-       pc.printf("Ultrasonik 1 : %.f Ultrasonik 2 : %.f \n", us1.read(), us2.read());
-       // Relay
-       pc.printf("relay\n");
-       relay = 1;
-       wait(1);
-       relay = 0;
+
+        pc.printf("\nTPA X \n");
+        tpax.Read();
+        for (i=2; i<=9; i++) {
+            pc.printf("%d ",tpax.getTemp(i));
+        }
+        pc.printf("\n");
+
+
+        wait(0.5); // 200 ms
+
+
     }
-}
\ No newline at end of file
+}