Correct way of passing wait(s) to functions?

12 Apr 2012

I have trouble trying to figuring out a proper and elegant way of passing wait time to functions. I'm not sure if this is rgiht but it is compilable. And if i want it to stop I can introduce a new function stop(). Will it work if i did it the way i did it at reverse()?

Essentially what the printf stament is in order to increase or decrease speed, it understands a formated string of characters such as "!a3F".

where !a stands for left wheel forward and the next two characters are hex.(00 -> 0% Speed and 7F -> 100% speed).

#include "mbed.h"

Serial pc(USBTX, USBRX);
Serial ax500(p9,p10);

void forward(float s){

      ax500.printf("!A7F\r");
      ax500.printf("!B7F\r");
      void wait(float s);
      ax500.printf("!a00\r");
      ax500.printf("!b00\r");


void backward(float s){

     ax500.printf("!a7F\r");
     ax500.printf("!b7F\r");
     void wait(float s);
     stop();
}
     
void stop(){

      ax500.printf("!a00\r");
      ax500.printf("!b00\r");
}

  
int main() {
int a,b,c;
a=b=c=2;
    
    while(1) {
    
              forward(a);
              reverse(b);
                   
}