code of robot bike

Dependencies:   SDFileSystem mbed

Fork of Robot_Bicycle by Chris LU

Revision:
10:3b952ea7fad4
Parent:
9:159bad8bae03
Child:
12:60593247555d
--- a/main.cpp	Mon Jul 18 09:36:16 2016 +0000
+++ b/main.cpp	Mon Jul 18 12:12:50 2016 +0000
@@ -48,6 +48,7 @@
 DigitalOut pin_pc2(PC_2);
 DigitalOut pin_pc3(PC_3);
 
+Serial pc(D1, D0);
 Serial BT(PC_6, PA_12);
 
 SDFileSystem SD_card(PC_12, PC_11, PC_10, PD_2, "sd");  //mosi, miso, sck, cs, name
@@ -67,6 +68,7 @@
 //********************************//
 
 //***** Variables from RasPi *****//
+bool interrupt = 0;
 char BTCharR = 0;
 
 float Vx = 0.0;
@@ -98,11 +100,15 @@
     
     setupServo();
     pc.baud(115200);
-    setup_spi_sensor();
+    BT.baud(115200);
+    if(setup_spi_sensor())
+    {
+        interrupt = 0;
+        pc.printf("SPI sensor ready.\r\n");
+    }
+    else interrupt = 1;
     init_Sensors();
     
-    BT.baud(115200);
-    
     reset_offset();
     
     timer1.attach_us(&timer1_interrupt, 4000);//4.0ms interrupt period (250 Hz)