Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of IEEE_14_Freescale by
Diff: main.cpp
- Revision:
- 14:a30aa3b29a2e
- Parent:
- 12:925f52da3ba9
- Child:
- 15:b10859606504
diff -r c2d14bf733a5 -r a30aa3b29a2e main.cpp --- a/main.cpp Thu Feb 27 00:38:13 2014 +0000 +++ b/main.cpp Fri Mar 07 21:49:22 2014 +0000 @@ -1,18 +1,40 @@ #include "mbed.h" #include "dbgprint.h" #include "robot.h" +#include "hcsr04.h" BusOut leds(LED_RED,LED_GREEN,LED_BLUE); Serial pc(USBTX, USBRX); robot bot; + +/* +//actual competition code, kinda +int firstSection(){ // drive forward and measure distance + tmpOut = bot.absDriveForward(targetAngle,3000); + // ping sensor + tmpOut = bot.absDriveForward(targetAngle,3000); + // ping sensor +} +int secondsection(){ + // second step + // etc +} +*/ + int main() { - DBGPRINT("AA\n\r",1); + // Initialize variables + leds = 0x2; char tmpchar = 0; - leds = 0x2; - const int* constbuf; + const int* constbuf; // displays values int tmpOut; double targetAngle=0.0; + DBGPRINT("AA\n\r",1); // to see if robot powers up at least + + // Initialize sensors + //hcsr04(2,1) : trigger_out(trigger); + + // Loop while(1) { DBGPRINT("BB\n\r",1); leds = leds^0x7; // toggle the LEDs for each loop @@ -109,8 +131,11 @@ DBGPRINT("dfac = %f\r\n",bot.dfac); break; case 'i': - bot.angfac*=2; - DBGPRINT("angfac = %f\r\n",bot.angfac); + //put distance ping here + bot.pingLeft.trigger(); + wait(1); + float pingresult = bot.pingLeft.inches(); + DBGPRINT("Distance = %f\r\n",pingresult); break; case 'k': bot.angfac/=2;