Subversion Repositories svnkaklik

Rev

Go to most recent revision | Details | Last modification | View Log

Rev Author Line No. Line
1 kaklik 1
#define THRESHOLD 44
2
#define POJEZD    OUT_A
3
#define VYHAZ     OUT_C
4
 
5
task main()
6
{
7
  Wait(500); // 5s
8
  SetSensor(SENSOR_2,SENSOR_LIGHT);   // senzor na caru
9
  SetSensor(SENSOR_3, SENSOR_TOUCH);  // poloha vyhazovadla
10
  SetSensorMode (SENSOR_3, SENSOR_MODE_PULSE); // koncak bude pocitat pulzy
11
  while (true)
12
  {
13
   PlaySound (SOUND_CLICK);
14
   start k_care;
15
   Wait(1000); // 10s
16
   stop utok;
17
   stop k_care;
18
   stop bumper;
19
  }
20
}
21
 
22
task k_care()
23
{
24
  SetPower (POJEZD,OUT_HALF/2);
25
  OnFwd (POJEZD);                  // dojezd k care
26
  while (SENSOR_2 > THRESHOLD);
27
  Off(POJEZD);
28
  OnRev (POJEZD);
29
  SetPower (POJEZD,OUT_FULL);
30
  OnFor (POJEZD, 30);
31
 
32
  PlaySound (SOUND_LOW_BEEP);
33
  start utok;
34
  start bumper;
35
}
36
 
37
task utok()
38
{
39
  ClearSensor (SENSOR_3);
40
  while (SENSOR_2 > THRESHOLD);    // jed, kdyz nas neco dotlaci k care
41
  stop bumper;
42
  SetPower (POJEZD+VYHAZ,OUT_FULL);
43
  OnRev (POJEZD);
44
  OnFwd(VYHAZ);
45
  while (0 == SENSOR_3);
46
  Off(VYHAZ);
47
  Off(POJEZD);
48
 
49
  start k_care;
50
}
51
 
52
task bumper()
53
{
54
  Float(VYHAZ);
55
  ClearSensor (SENSOR_3);
56
  while (0 == SENSOR_3);
57
  OnRev(VYHAZ+POJEZD);
58
  Wait(50);
59
  Off(VYHAZ+POJEZD);
60
}