#include "eyebot.h"

int main ()
{ int i, min_pos, scan[360];

  while (KEYRead()!=KEY4)
  { LCDClear();
    LCDMenu("", "", "", "END");
    LIDARGet(scan);
    min_pos = 0;
    for (i=0; i<360; i++)
    { if (scan[i] < scan[min_pos]) min_pos = i;
      LCDLine(i,250-scan[i]/50, i,250, BLUE);
    }
    VWSetSpeed(300, 180-min_pos);
    LCDSetPrintf(20,0,"minimum at %d (%d)\n", min_pos, scan[min_pos]);
    if (scan[min_pos] > 5000) VWSetSpeed(0,0); // stop
    OSWait(100); // 0.1 sec
  }
}
