/* ------------------------------------------------------------------------
File: example.c
This program demonstrates motors, buzzer, and display.

This program uses the Engr/CS 101 Version 2 robotics library for
Version 6 of the controller board.

Keil C headers are not guarded.  If robotics library is used, its header file 
should be the only included file.
---------------------------------------------------------------------------*/

#include "robotics6a.h"

/* Constant declarations */
#define DELAY_TIME 20   /* about 1 sec */

void main (void)
{ 
   /* Variable declarations */

   /* Initialization */
   InitializeMotors();
   InitializeDisplay();
   InitializeIO();
   WriteString("/Initialization done");
   Delay (DELAY_TIME);  /* Wait about 1 sec */

   while (1)  /* Repeat forever */
   {
      Beep (1);

      WriteString("/Forward");
      SetMotor (1, 255);
      SetMotor (2, -255);
      Delay (DELAY_TIME*5);
      AllStop();

      WriteString("/Left Turn");
      SetMotor (1, 255);
      SetMotor (2, 255);
      Delay (DELAY_TIME*2);
      AllStop();

      WriteString("/Reverse");
      SetMotor (1, -255);
      SetMotor (2, 255);
      Delay (DELAY_TIME*5);
      AllStop();

      WriteString("/Right Turn");
      SetMotor (1, -255);
      SetMotor (2, -255);
      Delay (DELAY_TIME*2);
      AllStop();

      Beep (2);
      Delay (DELAY_TIME*2);
   }
}
