Terrabots / Mbed 2 deprecated DUMP_TRUCK_SPR2017

Dependencies:   Tracker mbed MotorV2 SRF05 nRF24L01P

Fork of DUMP_TRUCK_TEST_V1 by Terrabots

Files at this revision

API Documentation at this revision

Comitter:
simplyellow
Date:
Tue Mar 14 20:10:27 2017 +0000
Parent:
10:cf77da9be0b8
Child:
12:502cf4fc6d98
Commit message:
dump truck stops as expected when within 20cm of an object (from front).

Changed in this revision

DumpTruck.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/DumpTruck.cpp	Tue Feb 28 21:11:48 2017 +0000
+++ b/DumpTruck.cpp	Tue Mar 14 20:10:27 2017 +0000
@@ -2,15 +2,15 @@
 
 DumpTruck::DumpTruck(int truckId) : truckNumber(truckId) {
     truckNumber = truckId;
-    track = new Tracker(p29, p30, p15);
+        //track = new Tracker(p29, p30, p15);
     // PWM: 21, 22, 23
     // DIR: 27, 28, 29
-    frontMotor = new Motor(p21, p27);
-    turnMotor = new Motor(p22, p28);
-    bedMotor = new Motor(p23, p29);
+    frontMotor = new Motor(p23, p28);
+        //turnMotor = new Motor(p22, p29);
+        //bedMotor = new Motor(p23, p28);
     //bed = new IMU(@@@@@@@);
     //nrf = new Transceiver(@@@@@@);
-    srf = new SRF05(p15, p16);
+    srf = new SRF05(p15, p16); //trigger, echo.
     tooClose = false;
 }
 
@@ -31,12 +31,12 @@
 }
 
 void DumpTruck::stop() {
-    frontMotor->write(0.0f);
+    frontMotor->write(0);
 }
 
 bool DumpTruck::detect() {
     proximity = srf->read();
-    if(proximity < 100) {       //cm
+    if(proximity < 20) {       //cm
         tooClose = true;
     } else {
         tooClose = false;
--- a/main.cpp	Tue Feb 28 21:11:48 2017 +0000
+++ b/main.cpp	Tue Mar 14 20:10:27 2017 +0000
@@ -7,7 +7,9 @@
 */
 
 int main() {
-    while(1) {
+    
+    while(1) {        
+        printf("%f\r\n",(float)dump.detect());
         if(dump.detect()) {
             dump.stop();
         } else {
@@ -16,3 +18,4 @@
     }
     
 }
+