Subversion Repositories svnkaklik

Rev

Rev 1 | Blame | Last modification | View Log | Download

#define THRESHOLD 44
#define POJEZD    OUT_A
#define VYHAZ     OUT_C

task main()
{
  Wait(500); // 5s
  SetSensor(SENSOR_2,SENSOR_LIGHT);   // senzor na caru
  SetSensor(SENSOR_3, SENSOR_TOUCH);  // poloha vyhazovadla
  SetSensorMode (SENSOR_3, SENSOR_MODE_PULSE); // koncak bude pocitat pulzy
  while (true)
  {
   PlaySound (SOUND_CLICK);
   start k_care;
   Wait(1000); // 10s
   stop utok;
   stop k_care;
   stop bumper;
  }
}

task k_care()
{
  SetPower (POJEZD,OUT_HALF/2);
  OnFwd (POJEZD);                  // dojezd k care
  while (SENSOR_2 > THRESHOLD);
  Off(POJEZD);
  OnRev (POJEZD);
  SetPower (POJEZD,OUT_FULL);
  OnFor (POJEZD, 30);

  PlaySound (SOUND_LOW_BEEP);
  start utok;
  start bumper;
}

task utok()
{
  ClearSensor (SENSOR_3);
  while (SENSOR_2 > THRESHOLD);    // jed, kdyz nas neco dotlaci k care
  stop bumper;
  SetPower (POJEZD+VYHAZ,OUT_FULL);
  OnRev (POJEZD);
  OnFwd(VYHAZ);
  while (0 == SENSOR_3);
  Off(VYHAZ);
  Off(POJEZD);

  start k_care;
}

task bumper()
{
  Float(VYHAZ);
  ClearSensor (SENSOR_3);
  while (0 == SENSOR_3);           // jed, kdyz nekdo narazi do vyhazovace
  OnRev(VYHAZ+POJEZD);
  Wait(50);
  Off(VYHAZ+POJEZD);
}