/* program to follow a dark line on light paper

   original version by Sara Marku, Marija Ivica, Thu Nguyen, Ruth Wu
 */


#include <stdio.h>
#include "MyroC.h"

int main () {

printf ("demonstration program:  Scribbler 2 robot follows a line\n");

printf ("establish Bluetooth connection to robot\n");
  //rConnect("/dev/rfcomm0");             // connection on Linux
  //rConnect ("/dev/tty.IPRE6-365897-DevB");   // curry
  rConnect ("/dev/tty.Fluke2-0958-Fluke2");  // perlis

  printf ("rConnect complete\n");
  eSpeakConnect();
  eSpeakSetGender("female");
  int sensors[2];

  rBeep(.7, 500);
  eSpeakTalk("Following the line");

  printf ("start following line\n");
  rGetLine(sensors, 10);

  while(1) {

    rForward(.7, 0.5);

    if (!sensors[0])
      rTurnLeft(.7, 0.3);
    else
      rTurnRight(.7, 0.3);

    rGetLine(sensors, 10);
  }

  eSpeakTalk("No more line to follow");
  rBeep(.7, 500);

  eSpeakDisconnect();
  rDisconnect();

  return 0;
}


